Object Oriented Analysis and Design: Can a Process Be a Class?

I understand that there are a few questions on OOD; this is not a duplicate (I hope) because of its specific nature - can functionality that processes data be a class?

Firstly, some background.

This was due to a discussion of my leader with me. I had to write a video upload class. His idea was to upload one class of video.

I thought about it and came up with the Video class, which stores the codec, file name, frame per second and, more importantly, byte arrays, and the VideoLoader class, which takes the file name, a link to the Video class, and then populates it.

My supervisor said this is not true. "The class should always have a state." I guess he meant private members here. "VideoLoader is just a bunch of processing functions. It doesn't have to be a class." I affirm that I am doing a denouement. VideoLoader may have an abstract base class in the future if we use different libraries (currently FFMPEG) to load videos.

However, it still bothers me. OOD always describes the location of verbs and nouns, and "processing-only classes" rarely go beyond the design of OOD. Does OOD have recommendations for this?
+3
source share
5 answers

I agree with your approach.

VideoLoader , , , . . , - -.

, Load Video .

public class Video
{
    private Video ()
    {
    }

    public Video Load (/* Parameters */)
    {
        Video video = new Video ();

        // Set up this video object

        return video;
    }
}

, Factory pattern.

: Factory . , . factory ( ).

+3

, "er", Loader, Runner, Writer .. , , , . , "Echoer". , , .

, , , , - . , , , , , , - .

, - , . , - OO- , (, ) , , .

+3

, ( ), Strategy. - , , .

+1

, . - . , , , .

, , factory ( ) flyweight. , , , . VideoLoader . , , -, ( Factory).

, , , - , , ""? , , .

- , RPG. , , . , . . , . , , . , ; , .

+1

The video processor may have a state.

  • The number of bytes processed.
  • The number of errors during processing.
  • Processing stage.
0
source

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


All Articles