Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [patterns-and-practices]

Design patterns (repeatable solutions to commonly occurring problems) and best practices in software engineering

1
vote
2answers
96 views

Improving the design of state transitions in a business application: the case of cancellation

I have to load certain object from the DB, and propagate it through few state and save after each state propagation. Let us illustrate this with the example of an Order entity. I now have to load few ...
1
vote
1answer
106 views

Is nesting component properties maintainable in the long run?

I'm building components in Vue.js. They look like this: <template> <form :schema="form.schema" :options="form.options"></form> </template> <script> export default { ...
1
vote
1answer
248 views

MVC, Services and DAO: Fundamental design choices, error handling and return values

Edit: There is no "right" or "wrong" answer here, I was merely trying to get people to share their dos and don'ts. Behind this rather vague topic I would like to address a few problems I've been ...
1
vote
1answer
132 views

Is it a common pattern in Python to have instance variables assigned in a constructor start with an underscore?

I recently started using UtilSnips, a Vim plugin allowing for a certain level of automation while coding by using template-like code snippets for common code fragments (class and function definitions, ...
1
vote
2answers
7k views

Best practice for unused inherited virtual functions (implementing superclass methods)

Let's assume I have a hierarchy of several classes each derived from each other using virtual functions. The base class acts as an interface and defines functions, which may not be required by all of ...
1
vote
1answer
878 views

Javascript heavy page/application - best practice for handling errors

Consider an application that contains a number of pages with a relatively large amount of javascript present, or a predominantly JS powered application. The script handles a number things, such as: ...
1
vote
1answer
116 views

How to prevent corrupting an hierarchical XML tree?

We have an XML tree which stores the relationship between folders and video files. So each folder could be the artists name and below it we have the videos of the artist. Also each folder can have ...
1
vote
1answer
17 views

How to organize work with objects containing different quailties of video

I run into a quite common case of handling Video files with different quality of a video, when the app (on android in this case) should save and use one or another video file depending on a user ...
1
vote
1answer
159 views

How to design service layer when working with model objects and relationships

I have a simple relationship where top-level items (Recipe) have a one-to-many relationship to children (Ingredient) and each item has a unique identifier (ID). For simple CRUD operations the flow is:...
1
vote
2answers
69 views

Mapping entities to VMs and back - should we use operator overloading or constructor + a convert method?

I got the following entity and VM: public class Student { public int ID {get;set;} public string FirstName {get;set;} ... } public class StudentVM { public int ID {get;set;} ...
1
vote
1answer
360 views

How to organize the management of resources for OpenGL?

I write my own 3D-graphics engine for education and have some difficulties with it's architecture. I wrote classes like OpenGLTexure, OpenGLMaterial, OpenGLGpuProgram, etc. I also wrote a class ...
1
vote
2answers
76 views

What is the name of the interface-implementation pattern applied to modularisation?

At work we have a project where we're pushing pieces of the monolith into modules. (A java project making smaller maven modules that we pull in via maven dependencies). The pattern we're using pushes ...
1
vote
1answer
239 views

How to decide level of Single Tenancy vs Multi Tenancy for application

How would one implement a multi tenancy application structure with the following technologies: Multiple SQL Server Databases (One per tenant) Asp.Net Entity Framework Active Directory and possibly ...
1
vote
2answers
1k views

Design pattern for managing three different objects

I´m looking for the best way to solve following problem: I have three lists of different objects: AppleJuice, OrangeJuice & Juice. All Juice properties exists in AppleJuice & OrangeJuice ...
1
vote
1answer
117 views

Name pattern for quickly find descendents with SQL (PATH column with [TopId]…[DirectAncestorId].[OwnId]) NO nested sets

I read a long time ago about a pattern/technique for easily querying for all "descendants" of a record (no need to use CONNECT TO, which is not standard and not available with JPA). I remembered the ...
1
vote
1answer
1k views

JSP in Javascript file or multiple AJAX requests

I've been thinking about how I want to load my data for some checkboxes in an AngularJS app. I'm generating multiple checkboxes based on 2 JSON objects that are currenty hard-coded in the a Javascript ...
1
vote
1answer
226 views

How do you deal with errors in enumeration / list processing (lowish-level API)

Ive struggled with variants of this problem many times, experimenting with different solutions, happy with none. Abstract: Enumerating a list of items, an error for one item does not affect the ...
1
vote
0answers
25 views

Doing operation on entity or dto

I use jpa and spring. I have facade where I convert habitually entity to dto. In the service layer, I call method to repository to get entity. For display, I need to do some operation on data. Is it ...
1
vote
0answers
114 views

What Design Pattern to use to render PDF pages for a PDF Proposal?

I want to create a set of patterns to use for rendering a PDF Proposal (a set of PDF pages). I have made a good start, but not clear on how to proceed when more complexity is involved. I am using ...
1
vote
0answers
95 views

When “cloning” an object in javascript should the clone behave as the original?

I'm using the webgl framework three.js. Most of the classes can be "cloned" via a .clone() method. Wikipedia seems to be very strict when it defines "cloning". In computer science, cloning ...
1
vote
0answers
400 views

Create account flow in microservices architecture with different services for account and auth

I'm developing an application based on microservices architecture. Currently my goal is to implement 'Create user' flow. But I'm not sure quite sure what is the right way to do it. My problem is as ...
1
vote
1answer
1k views

RabbitMQ Race conditions / Dependent messages

I'm currently working on a project, where we'll have to keep a local system in "sync" with a remote application. For example if a new customer is created in the local application, this customer must ...
1
vote
0answers
78 views

Making variables public in MVC pattern

In the MVC pattern, is it good programming practice to make all instance variables in the view(GUI) public so that the controller has easier access? I started to make setters and getters for ...
1
vote
2answers
70 views

Public Data Object but privately accessible field to select class

This is a software design question. Not sure how to ask, so I'll illustrate with a scenario. I'll update the title to help reference for others if there is a better way to ask. Scenario BizLogic is ...
1
vote
0answers
121 views

Relying on file hash for data synchronisation across mobile and server

Imagine a client-server app that lets user upload images/documents etc. to server and then lets users who have access, retrieve and view them later on their respective mobile devices. So the flow is ...
1
vote
0answers
107 views

Algorithm for evaluating line breaks efficiently [closed]

Consider following problem : Given: String input with the length n Font(-metrics) - potentially slow in usage Bounds of an abstract Textview which shall contain the text in a specific manner: e.g ...
1
vote
0answers
190 views

Decreasing MongoDB Load

I have some stream workers. They are listening to twitter stream and save into mongodb. I need to aggregate saved tweets for intermediate analyze result. I have analyzer workers. They are periodically ...
0
votes
5answers
8k views

Is it a good practice to wrap collection in Java? [closed]

I came across a snippet like this, and find it's over engineering. Is it a good practice? public class SchoolList extends ArrayList<School> { } public class School extends ArrayList<...
0
votes
3answers
325 views

2 methods that are 75% the same? [closed]

I have code that violates the DRY principle and I would like to consolidate 2 methods as much as I can, but the problem I am facing is that they have some differences, I would say they are about 75% ...
0
votes
3answers
2k views

How can I explain this is an anti-pattern? [closed]

I recently started at a new job. The existing system works OK but is poorly designed and hard to maintain, and they are planning to rebuild it in MVC and I fear it will be much worse. (Not because ...
0
votes
3answers
476 views

S.O.L.I.D. principles

I have a small question. Which approach is correct in the context of SOLID principles? 1 or 2 ? In the first case, the "CreateTask" method does not return the Task object, but places it on the list ...
0
votes
3answers
145 views

One method with many behaviours or many methods

This question is quite general and not related to a specific language, but more to coding best practices. Recently, I've been developing a feature for my app that is requested in many cases with ...
0
votes
1answer
142 views

How to write clean code accessing nested members on higher abstraction levels in c#

What are best practices for cleaner code style when accessing nested members on higher abstraction levels. class A{ B b; void Do(){b.c.d.e.f.g.value;} } class B{public C c;} class C{public D d;} ...
0
votes
3answers
693 views

Check a boolean before setting it in a loop, or just set it

I have a rather tight loop with the following check to see if balance had ever been positive: balance_null = True while (crazy_loop()): ... if 0.0 < balance: balance_null = False ...
0
votes
2answers
128 views

Pattern name for a class inheriting of a generic based on itself

I'm wondering if there is a name for the pattern of defining a generic class with one type argument where the type inherits the defining class. For example public class A<T> where T : A<T&...
0
votes
1answer
148 views

Is it a bad practice to use external files for storing SQL templates?

I am working on a report system which aggregate a lot of data from multiple sources (databases and internal APIs). Among other things I communicated with another departaments and told them I need some ...
0
votes
1answer
91 views

How to design interface communication beween objects?

I'm stuck on a lightly philosophical question for me. I have three classes and I'm not sure how to make them related to each other. I have few competing approaches all of them standing on equal ground ...
0
votes
2answers
3k views

How to implement a hybrid role-based access control model?

I am writing an enterprise web-forms-frontend application for in-house use. It has Direct access control (DAC) masquerading as Role-based access control (RBAC). For anonymization purposes, let's ...
0
votes
3answers
17k views

How to design the classes for a simple shopping cart example using Strategy Design Patterns

First year of Software Engineering, and we're learning OOP within Java. Came across an extension task to gain more credits. But could not think of what to do: First Step: Design a checkout system ...
0
votes
1answer
384 views

Apply latest methods and practices in highly sophisticated legacy application

Currently I am working on a health related application which was being developed for 5 years and lot of developers have contributed in it. The application is quite complex and highly used by lot of ...
0
votes
1answer
96 views

Does a create() method exist as part of a pattern? [closed]

Is there something special(i.e. a design pattern being related) to a method named create()? Background The case is, I often make some instances of objects (of the same class/prototype). These ...
0
votes
2answers
526 views

When should you create/destroy underlying object in a class that wraps it

(note: I used Java to make it easer to explain my question, but the actual language is irrelevant for this dilemma) TL; DR: I have a wrapper around some underlying class. At which point should I ...
0
votes
2answers
127 views

How does one design his various architecture/business models?

I'm currently learning about various application design approaches and there's one thing I can't really get my head around. Let's say I have a physical device in my network, an IP surveillance camera....
0
votes
1answer
153 views

Methods linking bad/good practices

I have multiple methods calling each other to simplify changing anything in the code and to avoid fixing errors and copy pasting. It looks like this: Is this a bad practice? Does it cause too much ...
0
votes
4answers
130 views

Is there a pattern or best practice for returning dynamically typed data?

I have a method that returns the percentage change of a data in a certain period. After calling that method, i need to know if in the current period the data increased, decreased or is the same when ...
0
votes
2answers
62 views

Are support arguments passed to functions that help skip certain checks a trap?

Often times, through my framework's importing side of things, I have access to certain data that functions I'm about to use will certainly need themselves. I have "resolvers" that these said ...
0
votes
1answer
158 views

Is it bad practice to hard-code values in ASP.NET's web.config file?

I work for a company that is building a web application with ASP.NET & MVC, which was last worked on a few months ago. I am part of the team working on the project and have encountered values (...
0
votes
2answers
67 views

Restore backup with recent changes (not included in backup)

For a web application I was asked to design a backup strategy. At the moment there are hourly full backups (database and files). In light of the GDPR, and because it's just the way it should work, ...
0
votes
1answer
3k views

Best Practice for handling data sync with React Native, MobX and REST?

We're developing an app using React Native and MobX for the state stores, and also using a Web API REST service for the GETs and POSTs. All is going well, so far we're able to use FETCH to get the ...
0
votes
1answer
329 views

Keeping customer data in sync between master and multiple clients

We have a master system storing customer data. Data is replicated to client systems (channels) at night. During the day data can be updated by users/customers on the master as well as on the clients. ...