Questions tagged [design-patterns]

The tag has no usage guidance.

6 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
0
votes
0answers
10 views

Best way to code a shopping cart consisting of items with different properties

This is an interview question. Interviewer wanted a scalable solution Goal is to find value of shopping cart. Cart could have 3 different types of items(Physical,Digital,URL). Only Physical Items have ...
0
votes
0answers
24 views

Is there an appropriate design pattern for this problem?

In terms of good OOP design, what is the best way to structure the code described below. The data I have a set of commands. Each command has an identifier, deadline, and a set of jobs to be done. Each ...
0
votes
0answers
23 views

Abstract syntax tree: expression->operation->lhs|rhs vs expression->lhs|operation|rhs - what should I take into account in decision?

I am trying to build class hierarchy for the abstract syntax tree of First Order Logic as specified in the grammar https://github.com/antlr/grammars-v4/blob/master/fol/fol.g4 (ANTLR parser generator). ...
0
votes
0answers
16 views

How do I erase the “shadow-world” antipattern?

In this antipattern, you have level-0 constructs of the language, which are then abstracted over by creating level-1 constructions, and these level-1 abstractions are abstracted over by creating level-...
0
votes
0answers
30 views

What are the pros and cons of these two coding patterns/structures? And do they have a formal term?

I have traditionally been doing things like this: function test() // A { if (/* conditions */) return true; else return false; } Of late, ...
0
votes
0answers
33 views

Finite state machine for a modified traffic controller

Consider a traffic light controller for an intersection of a main street and a smaller street. Both streets are one-way streets. The intersection has two traffic lights, one for each street. In normal ...