Questions tagged as 'design-pattern'

2
answers

How to make a database connection using the Singleton project pattern

Well I do a lot of web applications, where all of them I use database, and every time I go to do a new project, I create a file responsible for doing the queries with the database (CRUD). I just want to change this, I want to make a file wher...
asked by 07.08.2014 / 17:41
1
answer

What is an exponential backoff?

What is it? What's the use? In which situations can you use it? Is there just one strategy or several? ( Example: Fibonacci backoff)
asked by 01.09.2018 / 03:19
1
answer

Design Pattern Classifications

My college professor passed the following classification of the design patterns: Creation: Abstract Factory; Builder; Factory Method; Prototype and Singleton. Behavioral: Bridge; Command; FlyWeigth; Iterator; Observer; State; Strategy and...
asked by 29.11.2017 / 04:14
3
answers

Refactor the code using the factory pattern without using the if-elseif condition

I have the following Factory . In it I instantiate a class responsible for parsing the file in question. In order to instantiate this parser, it is first checked under the conditions if that parser is the correct one to perform the process...
asked by 08.05.2018 / 02:34
1
answer

Method returns instance after definition of property [duplicate]

Is there a name for the practice or pattern for this code snippet? Example: <?php class Pessoa { //... public setNome($nome) { $this->nome = $nome; return $this; } //... }     
asked by 13.08.2016 / 19:13
1
answer

Can the controller send email?

In a controller called activities, I have a method called reminder. This method, receives an id, searches for that activity based on this id and sends an email to the moderator of that activity with data of the same. Is this method with 'too muc...
asked by 06.12.2014 / 20:05
1
answer

Why use nested classes in Ruby?

I see things like: class Teste class Foo end class Bar end end Use classes within classes ... Can anyone tell me why? Is not it better and more correct to use modules? module Teste class Foo end class Bar...
asked by 05.12.2014 / 12:06
1
answer

What are the layers and names of folders to organize projects?

I have an application that needs to be developed as follows: Web Application (probably MVC) Web Server Application (WCF - Will run on IIS) Client Server Application (WCF Windows Services) Client Application (WPF), there are also Delphi...
asked by 07.11.2014 / 01:38
1
answer

Instantiate the object of a Map only when necessary based on a regex

I have a Factory that instantiates the PARSER responsible for extracting information from a particular invoice format. To determine the invoice format I use regex. I loop every regex added to Map and check if the regex is fo...
asked by 08.05.2018 / 14:51
1
answer

NodeJs api with promisses

I'm developing an API in TypeScript with NodeJS and MariaDB; when I do an operation with the bank, right below I have a if to check if an error has occurred. productDao.save({name:"Notebook Dell", price:"5000"}, function(err, res){ if(err...
asked by 29.06.2017 / 19:46