Multiple Controllers appropriate with one entity in spring framework -
i'm starting develop website use spring framework.i have 3 controller.there newcustomercontroller
,editcustomercontroller
, deletecustomercontroller
.these controllers mapped view use create update , delete, create customer
.
so, know.is appropriate declare controllers this.
thank
the answer question subjective , maybe more topic https://softwareengineering.stackexchange.com/. however, there spring related comment.
there few principles attempt @ guiding developers of how strike balance when thinking designing classes. 1 of single responsibility principle.
in object-oriented programming, single responsibility principle states every class should have single responsibility, , responsibility should entirely encapsulated class. services should narrowly aligned responsibility
a catchier explanation
a class or module should have one, , one, reason change.
however, still hard reason properly.
nevertheless, spring gives means (think of statement poetic freedom of interpretation). embrace constructor based dependency injection. there quite few reasons why should consider constructor based dependency injection, part relevent question adressed in quote blog
an faced argument is: “constructors verbose if have 6 or 7 dependencies. fields only, fine”. awesome, you’ve worked around clear indicator code write doing way much. increase in number of dependencies type has should hurt, makes think whether should split component multiple ones.
in other words, if stick constructor based injection, , constructor turns bit ugly, class doing , should consider redesigning.
the same works other way around, if operations part of logical whole (like crud operations), , use same dependencies (now "measurable" count , type of injected deps) no clear ideas of can cause operations evolve independently of each other, no reason split separate classes/components.
Comments
Post a Comment