Questions tagged [design-principles]

Design principles are ideas that guide developers toward certain goals in software design.

Software has many different desirable quality aspects -- among them are reliability, security, maintainability, efficiency, and size; and these are all impacted by choices made by the developers. Software design principles tend to focus on the maintainability aspects of quality: is the code loosely coupled, or does it have many dependencies that make it hard to use? Is the code highly cohesive, or is a collection of unrelated information needed to use a module? Is the code readable and understandable? Is the code testable? Is the code usable and reusable? Is the code simple or complex?

Various design principles can be used by developers to advise them in making choices that will yield highly cohesive, loosely coupled, simple, maintainable designs. The SOLID design principles are an example of specific design advice for object oriented projects. The Principles of User Interface Design provide design advice for creating user interfaces.

309 questions
1
vote
3 answers

Can someone explain how javax.servlet.http.HttpServlet methods like service(),doGet() and doPost() can be based on strategy pattern?

I read somewhere that javax.servlet.http.HttpServlet: service() method, plus all of the doXXX() methods that accept HttpServletRequest and HttpServletResponse objects as arguments. are based on a strategy pattern. I am not clear about this. It will…
1
vote
1 answer

Why are maximally cohesive classes not advisable or possible to create?

I'm learning the book of Robert C. Martin "Clean Code" (2009) and I've stumbled upon the concept of cohesion (Chapter 10). Robert quotes: A class in which each variable is used by each method is maximally cohesive. In general it is neither…
1
vote
1 answer

How can remove conditional statements while adding the common responsibility to the class?

I am building up a validation engine. There are common rules, which I have consolidated in a parent interface static method. public interface EmployeeValidator { Predicate build(Employee employee); static…
1
vote
1 answer

Reuse same variable name twice within a for loop

for i in rates: if input_currency == currency: if output_currency in rates[currency]: pass else: for i in rates: Is it generally a bad thing to use the same variable i again within a for loop? Even if I…
michafranz
  • 13
  • 2
1
vote
1 answer

Authorizing in controller constructor vs form request

When should I authorize in controller constructor using authorizeResource like here and when should I use Authorizing Form Requests like here?
1
vote
1 answer

What does "architecture that is specifically related to the purpose of the software application" mean?

Interested to know more about Software Architecture and started reading Design Principles and Design Patterns Paper by Robert C Martin. I was confused at the below highlighted statement, What is software architecture? The answer is multitiered. At…
1
vote
0 answers

Is it correct to encapsulate KafkaTemplate/handling methods in your own wrapper(and how)?

I try to introduce apache Kafka to our project and change projects architecture to producer-consumer. I experiment on a new test project. For example, I have one producer and two consumers. It is different spring-boot applications(microservices).…
ip696
  • 6,574
  • 12
  • 65
  • 128
1
vote
2 answers

Is checking existence of a method inside a class a violation of SOLID principles?

I have a class called Bird that accepts array of birds in the constructor. I am trying to implement a function inside it that will check if any of the birds is currently flying, keeping in mind that all code should comply with SOLID principles. I…
black_belt
  • 6,601
  • 36
  • 121
  • 185
1
vote
4 answers

Which implementation is better (DRY and KISS)

Below I have methods to return month name. In first one implementation I use switch/case, this method is longer and validation is in the last line. On second one I make validation in first line and instead of switch/case I declared table with months…
Anna
  • 39
  • 5
1
vote
1 answer

Is Inversion of Control a pattern?

According to some information, IoC is a principle. https://www.tutorialsteacher.com/ioc/introduction But elsewhere it is a pattern. What is Inversion of Control? The Inversion of Control (IoC) and Dependency Injection (DI) patterns are all about…
1
vote
1 answer

Azure Function API Versioning - How to structure my code?

I have created a demo microservices application implemented with the help of Azure Function Apps. For separation of concerns, I have created an API Layer, Business Layer, and a Data Layer. The API layer, being the function app, calls the business…
j Doe
  • 11
  • 1
  • 3
1
vote
1 answer

Singleton Polymorphism

Let's assume that i have singleton respresentation of chess board consist of double dimnesion array of cells. Sometimes I want that representation to be consider as board of rows, sometimes as colmumns, sometimes as grids, but every of this case…
1
vote
1 answer

Entity lazy methods and Dimetra law

I have entity: @Entity @Table(name = "CARDS") public class Card { @ManyToOne @JoinColumn(name = "PERSON_ID", referencedColumnName = "ID", nullable = false) private Person person; @OneToMany(mappedBy = "card") private List
ip696
  • 6,574
  • 12
  • 65
  • 128
1
vote
1 answer

What pattern or principle to use, in order to simplify generation of content that is based on lot of parameters?

In a situation, where you need to generate a bunch of , <meta name="description"> and <h1> tag contents, based on many query search parameters for thousands of pages. What principle or pattern is best fit in a situation like that? For…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/design-patterns" class="post-tag grid--cell" title="show questions tagged 'design-patterns'" rel="tag">design-patterns</a> <a href="../../questions/tagged/conditional-statements" class="post-tag grid--cell" title="show questions tagged 'conditional-statements'" rel="tag">conditional-statements</a> <a href="../../questions/tagged/simplify" class="post-tag grid--cell" title="show questions tagged 'simplify'" rel="tag">simplify</a> <a href="../../questions/tagged/design-principles" class="post-tag grid--cell" title="show questions tagged 'design-principles'" rel="tag">design-principles</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Feb 15 '18 at 11:37">asked Feb 15 '18 at 11:37</time> <a href="../../users/4907801/igor" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/4907801.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Igor " /> </a> <div class="s-user-card--info"> <a href="../../users/4907801/igor" class="s-user-card--link">Igor </a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">43</li> <li class="s-award-bling s-award-bling__silver" title="1 silver badges">1</li> <li class="s-award-bling s-award-bling__bronze" title="8 bronze badges">8</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-48219264"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>1</strong></span> <div class="viewcount">vote</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/48219264/is-it-better-to-wrap-chain-of-responsibility-functionality-than-have-it-direct" class="question-hyperlink">Is it better to wrap chain of responsibility functionality than have it directly in a class?</a></h3> <div class="excerpt">I have been focusing on learning programming principles and patterns but the chain of responsibility examples I have found all seem to contradict other principles/patterns. The placement of sethandler and nexthandler directly in a class that will do…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/java" class="post-tag grid--cell" title="show questions tagged 'java'" rel="tag">java</a> <a href="../../questions/tagged/design-patterns" class="post-tag grid--cell" title="show questions tagged 'design-patterns'" rel="tag">design-patterns</a> <a href="../../questions/tagged/architecture" class="post-tag grid--cell" title="show questions tagged 'architecture'" rel="tag">architecture</a> <a href="../../questions/tagged/software-design" class="post-tag grid--cell" title="show questions tagged 'software-design'" rel="tag">software-design</a> <a href="../../questions/tagged/design-principles" class="post-tag grid--cell" title="show questions tagged 'design-principles'" rel="tag">design-principles</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jan 12 '18 at 03:47">asked Jan 12 '18 at 03:47</time> <a href="../../users/9206862/dusky-pixel" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/9206862.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Dusky Pixel" /> </a> <div class="s-user-card--info"> <a href="../../users/9206862/dusky-pixel" class="s-user-card--link">Dusky Pixel</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">13</li> <li class="s-award-bling s-award-bling__bronze" title="3 bronze badges">3</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="s-pagination pager fr"> <a class="s-pagination--item" href="../../questions/tagged/design-principles_page=10" rel="prev" title="Go to page 10">Prev </a> <a class="s-pagination--item" href="../../questions/tagged/design-principles_page=1" rel="" title="Go to page 1">1</a> <a class="s-pagination--item" href="../../questions/tagged/design-principles_page=2" rel="" title="Go to page 2">2</a> <a class="s-pagination--item" href="../../questions/tagged/design-principles_page=3" rel="" title="Go to page 3">3</a> <div class="s-pagination--item s-pagination--item__clear">…</div> <a class="s-pagination--item" href="../../questions/tagged/design-principles_page=20" rel="" title="Go to page 20">20</a> <a class="s-pagination--item" href="../../questions/tagged/design-principles_page=21" rel="" title="Go to page 21">21</a> <a class="s-pagination--item" href="../../questions/tagged/design-principles_page=12" rel="next" title="Go to page 12"> Next</a> </div> </div> </div> </div> </div> <script src="../../static/js/stack-icons.js"></script> <script src="../../static/js/fromnow.js"></script> </body> </html>