Organize the code for similar funcionallity

(russo89) #1

I have a funcionallity named “Tasks” divided with two parts. The part one with acess for all users, and the part two with similar funcionality, different layout and restricted for a specific users.
All of this in frontend. What the best way to organize my code?
Create one controller for the part one and other controller for the part two, and two folders for views.
like this:

> frontend/controllers


> frontend/views


Or other structures for organize my code?
The “Tasks” is one example i have multiple cases of this.

(Alexander Makarov) #2

Depends on if these two functionalities are going to be developed differently. If they likely will, having a copy is fine. It won’t be a copy soon.

If these are going to stay the same forever a parent-controller with protected methods should be OK.

(russo89) #3

@samdark yes these are developed differently.
For you is not confused work with the example i refer?
Adding all time one “suffix” for the similar funcionallity?

another example is:





(Alexander Makarov) #4

You can use modules for such separation.

(russo89) #5

Ok, so my code would look like this correct @samdark ?



(Alexander Makarov) #6

Yes. I’d get TaskOne into taskOne module and TaskTwo into taskTwo module.

(russo89) #7

why? I did not understand? why get taskOne in module?

(Alexander Makarov) #8

Because these are two separate groups of related functionality. You can, of course, keep one of these out of the module.

(russo89) #9

Ok, thanks i will try.