oop - When should we prefer hard coupling over loose coupling? -
with hype loose coupling (with reason) , information ive read easy obsessed, point of becoming religious it. ive been wondering, when hard coupling favorible on loose coupling? when object candidate hard coupling? think depending on situation reduce complexity.
some examples appreciated.
advantages of hard/tight coupling
there few scenarios when tight coupling might leave better off. typically has speed of development , complexity of program.
very small projects/proof of concepts
in short term, loose coupling increases development time. theoretically, every service/client pair there need interface created well. hard coupling wouldn't worry dependencies. experience, many projects in school small enough tightly coupled classes okay. in cases when turn in assignment , never have touch again.
keeping things simple
often loosely coupled systems contain more components, adds more complexity program. bigger programs, complexity worth because expanding/modifying program exponentially easier , cause less bugs. however, small programs or programs 99% unlikely change, time spent trying program abstractions , remove dependencies, may not worth it. analysis paralysis more designing program.
concluding remarks
as whole never suggest"tightly coupled" classes better. however, interest of time , complexity "tighter coupled" classes can justified.
Comments
Post a Comment