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

4
votes
2answers
164 views

Factors for choosing between using a wrapper library or issuing command line process from my web application

I have a Java web application that makes use of certain libraries for example: Ghost Script for converting PDFs to TIFFs and Tesseract for OCR. There are java wrappers for both of these: Ghost4J and ...
4
votes
3answers
2k views

Architectural Patterns for a Game

So I've got a solution that contains a few big projects, which I'm trying to break down into smaller projects with more isolated responsibilities. This is a game I'm tinkering with -- I'm mainly a LOB ...
4
votes
2answers
285 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 ...
4
votes
1answer
350 views

Dangers when implementing features as plugins [closed]

What kind of problems have you encountered when building plugin interfaces for your application? And how did you resolve them? Background I want to refactor an application so that various features ...
3
votes
3answers
516 views

Why is quantity in software still written as “1 result(s)”?

Lately, I've been noticing that a lot of software, be it a website, a client application, or a video game, often write a representation of quantity as follows: "1 result(s)". Now, I can understand why ...
3
votes
6answers
2k 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 ...
3
votes
2answers
404 views

Architecture of modular software application

For this question, let's assume the following: OOP design principles are being followed. Modules generally do not consume more than one general concern, but different business purposes. Hybrid ...
3
votes
4answers
586 views

Function wrappers with no args: bad practice?

My colleague likes to write classes containing methods looking like this: public function doTaskA() { return $this->doTask('A'); } public function doTaskB() { return $this->doTask('B'); ...
3
votes
3answers
744 views

What is a good use case for native XML databases? [closed]

What would be a good use case to use a native XML database such as Apache Xindice and eXist-db? I have used XML features of SQL Server in the past and they were of great value, but there it is ...
3
votes
4answers
396 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 ...
3
votes
1answer
164 views

Should I follow patterns strictly?

I have a service which is an API client. It's goal is to instantiate a concrete client you tell it (different providers), implement it's methods (createRequest and doRequest) and forward their call ...
3
votes
3answers
156 views

Drawing lines with dashes in logs

It can sometimes ease readability to "draw" lines in a logfile. For example: noise noise ----------------------------- Starting Operation ABC blabla blabla ----------------------------- End of ...
3
votes
4answers
757 views

Keeping a ratio column that's the division between two other columns

I'm about to build a SQL table where I want to store currency orders. That means that I need to store how much I paid for a certain quantity, and the ratio between both quantities. So for example: +--...
3
votes
2answers
329 views

Is there a name for this pattern?

A while loop can be written as follows in C# (and many other languages): int someValue; int someTerminatingValue; while ((someValue = GetSomeValue()) != someTerminatingValue) { // Do something ...
3
votes
2answers
390 views

Does it break SRP to have concerns of data handling and object mapping inside a single class, as part of the DataMapper pattern?

Summary I want to look into separating the concern of "creating a populated object from database", to use inside my application. DataMapper pattern seems to be doing just that for me. DataMapper ...
3
votes
3answers
930 views

New Silverlight app. MVVM. RIA Services vs CSLA

Another 2 days of reading and watching demos and here we go. For my enterprise LoB Silverlight app I'm going to use: Prism for UI aspects and modularity. MVVM pattern (using Prism) ??? to bring data ...
3
votes
3answers
3k views

Violation & Solution for Single Responsibility Principle

EDIT 2017/02/13 - Check the repo as it is now. The first example is solving with SRP in mind, but later on introducing other principles of SOLID.. I should've explained that better. I'm trying to get ...
3
votes
2answers
157 views

Could this be called a decorator pattern?

I want to add some extra methods closely related to Book without extending Book. So I found the decorator pattern. Most examples I have seen are eg. extending an abstract decorator class which ...
3
votes
2answers
342 views

How to abstract transition between Views?

Our team is developing an application using WPF with MVVM. We want to make ViewModels reusable. With this intention we want to abstract the transition logic between Views (ViewModels, we use ...
3
votes
2answers
1k views

Pattern(s) about hierarchical settings overwriting

Assume that you have a hierarchy of organizational units: - Company -- Branches --- Departments ---- Teams Lets say I have some settings (for simplicity assume that they have the same properties) ...
3
votes
3answers
940 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 ...
3
votes
4answers
2k views

Best practice to sync long paths to filesystems where path length is limited?

I wrote a sync tool to synchronize folders/files from Alfresco to Windows. PROBLEM: In Alfresco, /files/can/have/very/very/very/long/filepaths/like/this.txt The Windows API prevents me from creating ...
3
votes
2answers
143 views

deriving , derived decorator classes. How? Does it sound like a good idea or are there more suitable ways?

I follow this example on decorator patterns to implement objects who's functionality can be dynamically be coupled together. Namely: class I: is the interface class, common to both "core" class and "...
3
votes
3answers
3k views

CRUD operations in DDD

I'm designing an application with DDD. I'm moving from flat POCO objects to strong domain models, so my question is: Would I have to call my basic CRUD operations (located in my repository layer) ...
3
votes
1answer
104 views

Is good or bad practice to share reporting modules between systems/apps?

At my new work, a few people want to share modules between systems/apps, and I'm a bit skeptical about it. Context: we have a lot of little apps living in different servers, some of them are ...
3
votes
1answer
116 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 ...
3
votes
5answers
1k views

Is it bad practice to supply command line arguments for unit tests

I am on C++ and using gtest as the main framework. Say I have a edge detection function I want to test that takes an image as an input and returns the edge detected image. I have 3 images ready to be ...
3
votes
4answers
1k views

Where to store average value in db?

I have a restaurant review app which stores reviews in a db, MySql. There's 2 tables. 1 for Restaurant. Another for reviews. To increase the performance, I am considering to store the avg review of ...
3
votes
1answer
1k views

Reading from a file and inserting into a database, a good practice

I am making an Android application which reads several JSON files and inserts the read information into tables in my database. For instance, there are three files: countries.json { "countries":...
3
votes
1answer
142 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....
3
votes
3answers
183 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'):...
3
votes
3answers
520 views

Nesting class and enums types

If an enum type is dedicate only to a specific class, does it make sense to declare it inside the class itself? I mean, would it help to understand that this enum type was designed to be used only ...
3
votes
1answer
293 views

Design patterns for handling patterns in object sequences

There some times appears a task when you have a sequence of object and you need perform some action when a particular pattern (subsequence?) occurs. As more concrete example we can imagine a log ...
3
votes
1answer
209 views

Naming a sending/receiving module. Does the pattern have a name? [closed]

I'm working on a simple piece of functionality (actually a ruby gem, but that is beside the point) which can be used to receive and persist incoming messages send and persist outgoing messages ...
3
votes
1answer
109 views

Rpc transferring data or Replication

I have services on 10 machines that stores data in database on these machines. And I have main server that needs to pull that data from these ten machines. What is better for this. Implement some rpc ...
2
votes
2answers
2k views

How Visual Studio could help to avoid duplicating code?

I work within a team of developers. Everyone is making their changes without carrying too much if the same thing is already implemented in the codebase. This leads to classes constantly growing and to ...
2
votes
6answers
1k views

Is “call and return” a pattern or an antipattern?

Imagine to have this code: class Foo: def __init__(self, active): self.active = active def doAction(self): if not self.active: return # do something f=Foo(false) f.doAction() ...
2
votes
2answers
218 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 ...
2
votes
3answers
168 views

Alternate approaches to creating custom forms in a web application

We are putting together some distribution software, selling about 150K SKU's. Some of our items have additional requirements in order to be sold that are dictated by our vendors. For instance one type ...
2
votes
2answers
2k views

Is it good OOP practice to pass object to object and have more than one instance of class?

Singleton pattern saying "there should be no more than one instance of same class", is this something one should stick to when designing PHP OOP applications? What are advantages / disadvantages? ...
2
votes
3answers
455 views

What are the differences between Threadpool and Object Pool patterns?

I was going through the ThreadPool pattern and it resembled the Object Pool pattern. The only difference that I can think of is that most explanation about the ThreadPool explicitly mentioned the use ...
2
votes
2answers
80 views

Question about a maintainable approach on how to handle changes in the UI inside the source code

Inside our UI there's an option to select something from a dropdown. Depending on what you choose inside that menu the rest of the fields inside the UI change accordingly. At the moment we handle it ...
2
votes
2answers
272 views

Is it a good idea to install more libraries than you need? [closed]

I decided to try Anaconda, it seems that too many large companies are using it. I was amazed by the number of libraries included by default installing: python-2.7.9-2 ... installing: conda-3.10.0-...
2
votes
2answers
981 views

Best approach for utility class library using Visual Studio

I have a collection of classes that I commonly (but not always) use when developing WPF applications. The trouble I have is that if I want to use only a subset of the classes, I have three options: ...
2
votes
2answers
802 views

Legal Applications of Metamorphic Code

Firstly, I would like to state that I already understand the 'vx' applications for Metamorphic code. I am not here to ask a question related to any of those topics as that would be inappropriate in ...
2
votes
2answers
207 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 ...
2
votes
1answer
2k views

How to handle “conditional fields” in Java?

I've run into several situations where a POJO where whether a field value is meaningful depends on the value of another field. An example, using Lombok (which we try to use to avoid boilerplate): @...
2
votes
3answers
226 views

Is there some software to manage a XP Project? [closed]

I was wondering if there's some software to manage a XP project. I'm starting a school project and I want to follow this methodology, but, we don't have a place to work. Each one works at home (in ...
2
votes
3answers
3k views

How to implement the repository pattern for an app that will change its database from sql to nosql on in couple of years?

I have been reading a lot about repository implementation. I am confused about which way to implement it for a project I am sure would change its data layer methods because of db migration from MS Sql ...
2
votes
3answers
1k 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 ...