java - Looking for feedback on a use of the Adapter pattern -


There is a fixed price type class in our domain model in a project that has a lot of numbers.

  public class BigValueType {Private Phu Foo; Private times; Private falcon falcon; // ...}  

We have realized that we want to "focus" in many different, some more special classes, which only have some subsets of this class's features. It seems that we want to do something like "different ideas" of this data.

  Public Sector Specialization A {Private Phu Foo; Private falcon falcon; // ...} public class specialization B {private times; Private falcon falcon; // ...} Private class specialization C {Private Phu Fu; Private times; // ...}  

However, the purpose of this domain model is to be general, and is not specific to this project during the future projects will include project-specific extensions, but The normal domain model will be excluded from these extensions. If we just define a bunch of classes, then it is likely that other projects using the domain model will have to write some different people of their own later. (We can not easily predict which views of this data will be useful.)

I think what we should do is write a project-specific adapter for this large category, presents. In this way, future users of the domain do not have to touch anything in the "normal" domain model to define new ideas for this information.

  Public class adapter A {Private BigValueType wrapped; // ... public ViewA (BigValueType wrapped) {// ...} public Foo getFoo () {returns wrapped.getFoo (); } // ...}  

It matters more to me than normal heritage because almost nothing happens in our high level class / interface.

Anyone react to this approach? First of all, it is important to understand that the problem you want to solve is of a large number of attributes. It is not necessary due to being a class, and if you want to refactoring only to be compatible with 'good' design principles, then I will reconsider the decision.

After saying this, it is a very big design in SOA's world, which is a big service, which takes complicated messages with very large features as a request. This service is then 'customized' to meet customers with different needs. So, your design should work well. Of course, it assumes that you already know all the potential ideas or you have to write new adapters for new customers.

This 'Optimization' can be done at two levels - User Interface Level (which is essentially your design - to customize the classroom) or at a lower level, such as at the database level, and this, In turn also modifies your main category, it depends on your application, users of your structure and so on.

An alternative approach to this can be the easiest way to do this - though expose data (fu, falcon, etc) from the main category, and customers have their own data Processing mainly provide CRUD features primarily on this data. Then your class behaves like a structure with a real business logic.

Any of these three methods should be fine, IMHO


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -