简体   繁体   中英

Any Design Pattern for this use case

I have a class that has certain fields say a Profile Class. Fields are Name, Designation, Work-place, Phone number etc. Now it might happen that in future we add some field to these classes. One method for sure is to manually add the fields and add the getter and setters for it. But is there a design pattern or way so that we have a provision to add new fields to our java class so that when we create an object we have that field added.

But is there a design pattern or way so that we have a provision to add new fields to our java class so that when we create an object we have that field added.

Well if you add any field then you have to modify your class. There is no other way

Design patterns are solutions to general problems that software developers faced during software development. Design patterns are to make design more maintainable but it does not mean you don't make any modifications

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM