Stack Exchange Network

Stack Exchange network consists of 174 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
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

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

-3
votes
1answer
92 views

Is it a good practice to always apply CSS styles to the innermost nested element? [on hold]

Let's say you want to center the text here: <div class="wrapper"> <div class="content"> <p class="body"> GUCCI GANG, GUCCI GANG, GUCCI GANG, GUCCI GANG, ...
0
votes
2answers
114 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
63 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 (...
2
votes
1answer
101 views

Traversing over two similar object structures using a pattern

Let's say I have an Object Structure like this that I import data into from a source: Reporting: Body: ReportingEntity: DocSpec Reports[]: ConstEntities[] DocSpec ...
1
vote
4answers
224 views

What should be the last entry in a switch/case statement?

When writing a switch statement that only ever has to deal with a known set of values (imagine an implicit enumeration), I find myself wondering what should be the last entry in the construct. I'm ...
4
votes
2answers
75 views

Handling disposables with dependency injection

I'm struggling to implement disposable objects via dependency injection, as the dependencies are injected in the constructor (and live as long as their containing object does), whereas I want the ...
2
votes
2answers
205 views

Should I fix known bad domains in user emails?

Checking my Sendgrid account I've noticed many drops due to "Known bad domain". Those bad domains often seem to have been caused due to user mistake. ***@gmal.com ***@gmail.com.br ***@hotmal.com I ...
0
votes
1answer
109 views

Enum as part of domain - enum + extension or consolidate into one class?

I have a program where the domain is focused around programs. As part of the domain, I have a 'ProgramType', which is an enum formed mostly via a string from the database but also via a bit of logic. ...
1
vote
1answer
42 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:...
2
votes
4answers
198 views

Inheritance best practice?

I'm fairly new to object oriented programming and have a question I've stumbled upon regarding inheritance best practice. I'm building a system for weapons in a game. I have a base class called ...
0
votes
1answer
134 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;} ...
-4
votes
5answers
427 views

Why do programmers like to stick to “Thou shalt” / “Thou shalt not” rules that define whether a code is of good or bad quality? [closed]

I'm not sure how to correctly describe my problem... Ever since I started learning how to program, I recognized that many more experienced programmers have very strict (and, in the POV of a beginner, ...
0
votes
2answers
122 views

DDD: Is there a place for “find or create” in the business logic

Some user actions quite naturally lead to find-or-create situations. For example, user logs into a system by alternative method and find-or-create is called give email. Or, another example, User is ...
0
votes
1answer
66 views

Best design pattern for Notification System => How to handle multiple languages and items

As always I came here to ask for some light in a design issue I am facing. I have a system that issues some notifications : PackageReceivedNotification PackageSentNotification ...
5
votes
5answers
477 views

With TDD, tests obviously fail first.But is that really true?

I have been taught that with TDD, the tests "naturally fail first but it is a good habit to run them anyway to see the red light". Well, but I am quite sure a unit test written first for a new feature ...
2
votes
2answers
195 views

Reading huge (up to 32 GB) file in multithreading env?

Goal: 1) huge file read in chunks each 1 MB long, 2) each one gets compressed and written to an another output file. Note: I am limited to .Net 3.5 only. Is there a known pattern how to parallelize ...
1
vote
0answers
47 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 ...
0
votes
0answers
46 views

Best practices to check permissions in a webapp based on api?

Let's say I build an api server and a angular/react/whatever client webapp. I can authenticate and store auth token, no issue with that. Is there andy best practice on how to handle users ...
3
votes
1answer
105 views

What is best practice for handling mapping arbitrary depth in arrays?

I have a set of data: id | name | parentid ------------------------ 1 | parent | 0 2 | child | 1 3 | child | 1 4 | parent | 0 5 | child | 4 6 | subchild | 5 7 | child | 4 ...
4
votes
1answer
103 views

Design pattern to instantiate implementations depending on properties

I have an interface: public interface MyInterface{} And two implementations: public class Imp1 implements MyInterface {} public class Imp2 implements MyInterface {} My program is a CLI. I want to ...
81
votes
6answers
15k views

Is it bad practice to enforce an execution order for unit tests?

I am writing tests for a project that consists of multiple submodules. Each test case that I have written runs independent of each other and I clear all data between tests. Even though the tests run ...
3
votes
1answer
136 views

What is the standard method of handling errors in a NodeJS web app?

I am currently working on a web application as a learning project, which has a NodeJS backend and uses a MongoDB database; however, I believe my question is not specific to the technologies I am using....
1
vote
2answers
64 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;} ...
3
votes
2answers
618 views

Best practice for exception handling in Java threads

long-time reader, first-time asker here. I have a service which writes data to a database in batches. It contains a buffer which is being watched by a separate thread. Whenever the buffer reaches a ...
0
votes
2answers
65 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, ...
2
votes
3answers
253 views

What design pattern for a sequence of processors over the same list?

Imagine you have a list of Objects - like a list or array of objects representing users - and two processors: one adds/delete/modify some user under certain circumstances the other does the same ...
0
votes
1answer
96 views

Name of different patterns of acting on data in libraries.

I contribute to a couple of open source software, and I've noticed two types of patterns when classes act on data. I am interested in the name of these patterns. The first is something that goes ...
0
votes
0answers
225 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
76 views

Creating a web portal to access multiple databases (security and best practice?)

I am looking to create a website. There will be a portal, from which the user (and thier associated users) can create/access one or more databases. There will be many different databases in the ...
0
votes
1answer
97 views

Should I make constant for values of three choices (trivalent/ternary)?

For two choices there is boolean. In my case, I have positive, negative, and neutral which are three choices and cannot be represented by boolean. I've see there's method Math.signum(x) in Java which ...
3
votes
6answers
555 views

Best approach - convert multiple conditional if -else in a more handy design

I have a class that handles the state of a response, called StockResponse. The code has multiple ifs to handle each state of the stock. Most of the cases has a default behaviour, but some conditions ...
1
vote
2answers
88 views

Bridging application development practices and game development practices

I previously ran into an interesting practice called occlusion culling in game development. I am still researching to gain more understanding of how it works, since this is mostly discussed in game ...
-1
votes
1answer
1k 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 ...
2
votes
1answer
152 views

Is it a best practice to use a mocking service for testing http requests?

Is it better to unit test using a mock library like 'nock' (nodejs) or to just test the server's http requests directly? Here is an example of my Express server test for testing if my server is up ...
5
votes
2answers
286 views

Designing event-driven architecture for multiple services

I've created about a dozen services for a intranet. Now I've gotten to the point that these services are more coupled to each other than I'm comfortable with, and I've been having problems where once ...
3
votes
3answers
147 views

Best practice to avoid partial branches

I do a lot of coding in python and got a lot of if conditions without an else statement so to say partial branches. E.g.: # if a certain kwarg was passed to a function call if kwargs.get('a_option'):...
1
vote
1answer
374 views

How to control optional dependencies of a header-only library in `CMake`?

I am developing my own header-only library that I want to use as a framework in other software. I am using CMake for setting up demo targets, tests, and so on. However, I am unsure how to deal with ...
2
votes
3answers
399 views

Is it OK to have a many-to-many relationship where one of the tables involved is already a junction table?

When planning our database, we ended up with a setup like this: We have Company, Product and Person. There is a many-to-many relationship between Company and Product, through a junction table ...
0
votes
3answers
429 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 ...
6
votes
1answer
283 views

Handle Optional Logging in High-Performance Library

I'm writing a library in C++ which needs to be as fast as reasonably possible. However, I'd also like to be able to provide logging in case a user (or me) needs to debug possible problems. This ...
20
votes
4answers
3k views

What are the practices you follow to avoid wrong data updates in big databases?

A typical advice before any production deployments is backup the DB first. This way, if the new update has some issue that can lead to potential data loss or logical data corruption, then you still ...
1
vote
4answers
362 views

Coworkers don't seem to care about best practices [closed]

I am a member of a 6 person team of software engineers within a 400 person department at a fairly well known company. We are responsible for the business applications our department uses, both third-...
1
vote
2answers
58 views

__init__ arguments differ from object attributes

Is the following class definition a good design? class Myclass: def __init__(self,num1,num2): self.complicated_tree = __class__.object_creator(num1,num2) @classmethod def ...
0
votes
0answers
45 views

Database catalogue values used for decisions in code or front-end

I was wondering what is your approach when you have a catalogue table in database and you have to make decisions in application or front-end code based on valued from this catalogue. Example: Table -...
1
vote
1answer
212 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 ...
3
votes
3answers
792 views

Is implementing INotifyPropertyChanged on a custom control a bad practice?

Imagine a Control is being created. It has some DependencyProperties and there are some properties which depend on the DependencyProperties, but doesn't need to be seen or updated from the outside. ...
1
vote
2answers
106 views

Bundling Model and Services in MVC pattern?

These days, all I hear is how MVC should contain additional layer called services, turning it into SMVC. But to me, it seems like too much of a decoupling and instead want to engineer my app something ...
3
votes
2answers
92 views

REST: How to deal with relative resources?

I'm designing an web app with React as front-end, and I'm trying to properly understand REST API practices. Reading resources online, one can get the idea that the REST API is seen kind of like an ...
2
votes
2answers
575 views

NoSQL/Mongo: Best practice for modeling 1:1 “relationships”?

I come from many years working with SQL Server. I am working now on a mobile game using GameSparks as the back-end which only supports NoSQL run on Mongo. I am creating a Computer Card Game and am ...
0
votes
1answer
118 views

In the react docs why is binding of *this* preferred over arrow functions for event handlers?

In the React docs, the constructor functions of class components contain lines where this is explicitly bound for event handlers e.g. in the docs for handling events class Toggle extends React....