Trying to Follow MVC - Seeking Good Design Advice

I just resumed work on an old project and was thinking about rewriting some parts of it.

My question is how to structure my program. I am trying to follow the MVC paradigm. I will start by explaining where things stand: the program manipulates 4 types of images: offset, dark, flat fields and lights. I have a class called Image that can represent all of them. Bending and darkness are subtracted from the Light, and then the Light is divided by a flat field. Initially, I was going to use 2 classes for this, one of which is called CalibrationImage, and the other is only Light. But the difference was only in one method, which would be the dividing function mentioned above. Otherwise they are the same. Therefore, I decided not to have two classes for this purpose.

The second main class in the program concerns the processing of several Image objects - this class is known as ImageStacker . Currently it contains Image objects in a mutable array. It can perform various operations on this array, for example, add all the images, calibrate them, etc.

This class also acts as a data source for the NSTableView object in the main window. I do not think that instead of having one mutable array, I should have 4 arrays, each of which will contain its own type of image (for example, an array for Lights, another for Darks, etc.). After the program begins its actual work, it will be dark, flat fields and offset frames. He then calibrates each object stored in the Lights array, and then stacks them. I feel this provides a program with a logical progression. It is also a little easy to visualize.

Is this a good program design? Does it comply with MVC? As I can see, my view is NSTableView , the controller is NSApplication , and Model is ImageStacker . But then Image feels that its not part of MVC, but I can't see how to write a program without it.

+6
source share
1 answer

My 2 cents: MVC is a presentation design template. I usually write my MVC applications with separate business layers and data, except for the MVC part. It’s normal that Image no different from the MVC pattern, it probably fits better into a class group that you would define as your business layer. There are many good books, blogs, and articles that talk about software design patterns, so I won’t repeat what they have already done. Just asking this question is a good start. I would advise you to monitor the viewing of content that is already available.

+1
source

Source: https://habr.com/ru/post/890155/


All Articles