design-patterns

Doesn't having more than 1 method break the Single Responsibility Principle?

筅森魡賤 提交于 2020-03-16 06:55:52
问题 I am quite confused with the Single Responsibility Principle. The Principle states that there should only be one reason for the class to change. The problem which I am facing is, any change to a method or any logic change in doing things would change the class. For example, consider the following class: class Person{ public void eat(){ }; public void walk(){ }; public void breathe(){ }; public void run(){ }; public void driveCar(Car car){ }; } Uncle Bob describes it as there should ONLY be a

Decorator pattern mess

狂风中的少年 提交于 2020-03-16 05:59:25
问题 I'm having a problem figuring out if I'm using the decorator pattern the right way. Let's suppose I'm working on a console application. In this application I have defined a simple IConfigPathProvider interface, which will provide a configuration file path to some class. public interface IConfigPathProvider { string GetConfigPath(); } The path is stored in the appSettings section of the console application's app.config file. public class AppSettingsConfigPathProvider : IConfigPathProvider {

sed delete lines between two patterns, without the second pattern, including the first pattern

只愿长相守 提交于 2020-03-11 14:56:33
问题 my input file looks like this: [1234] text text text [3456] text text text [7458] text text text I want to delete all lines between the patterns, including FROM_HERE and excluding TO_HERE. sed '/FROM_HERE/,/TO_HERE/{//p;d;}' Now i have: sed '/^\['"3456"'\]/,/^\[.*\]/{//p;d;}' but this command does not delete the line FROM_HERE too. for 3456 at the end the input file should look like: [1234] text text text [7458] text text text How can i achieve this? Thanks. 回答1: You could delete lines from

How i can process my payload to insert bulk data in multiple tables with atomicity/consistency in cassandra?

早过忘川 提交于 2020-03-05 05:05:08
问题 I have to design the database for customers having prices for millions of materials they acquire through multiple suppliers for the next 24 months. So the database will store prices on a daily basis for every material supplied by a specific supplier for the next 24 months. Now I have multiple use cases to solve so I created multiple tables to solve each use case in the best possible way. Now the insertion of data into these tables will happen on a regular basis in a big chunk (let's say for

How i can process my payload to insert bulk data in multiple tables with atomicity/consistency in cassandra?

别等时光非礼了梦想. 提交于 2020-03-05 05:03:06
问题 I have to design the database for customers having prices for millions of materials they acquire through multiple suppliers for the next 24 months. So the database will store prices on a daily basis for every material supplied by a specific supplier for the next 24 months. Now I have multiple use cases to solve so I created multiple tables to solve each use case in the best possible way. Now the insertion of data into these tables will happen on a regular basis in a big chunk (let's say for

How to use Lombok @SuperBuilder on Abstract classes with final fields

≯℡__Kan透↙ 提交于 2020-03-04 17:45:46
问题 Given the following classes with the Lombok annotations @Data and @SuperBuilder @Data @SuperBuilder public abstract class Parent { protected final String userId; protected final Instant requestingTime; } @Data @SuperBuilder public class Child extends Parent { private final Instant beginningDate; private final Instant endingDate; private final Collection<String> fields; } I am getting the following error appearing over the @Data annotation in the Child class: Implicit super constructor Parent(

Are Java Spring services evil as they are singleton? [closed]

≯℡__Kan透↙ 提交于 2020-03-03 04:43:11
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . I have read a number of discussions on web and stack which claim singletons to be evil. Like: root-cause-of-singletons and Why is Singleton considered an anti-pattern? I read comments like "singletons make code complex, pain to reuse and test". I work with code that has

Are Java Spring services evil as they are singleton? [closed]

ぃ、小莉子 提交于 2020-03-03 04:42:26
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . I have read a number of discussions on web and stack which claim singletons to be evil. Like: root-cause-of-singletons and Why is Singleton considered an anti-pattern? I read comments like "singletons make code complex, pain to reuse and test". I work with code that has

Create 3 Tier Architecture In DotNet Core 2.2 Web API C#

为君一笑 提交于 2020-02-25 07:00:49
问题 I am working on Web API Core 2.2 and need to design 3 tier architecture. How can I do it. My Project Structure as below In Web API Project.. public void ConfigureServices(IServiceCollection services) { services.AddDbContext<HrmsDbContext>(opt => opt.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); } In DAL (Library project, I have made my DBContext and provided connectionstring like below. Is there any better so that I had not provide connectionstring at two places? and

Create 3 Tier Architecture In DotNet Core 2.2 Web API C#

风格不统一 提交于 2020-02-25 06:59:14
问题 I am working on Web API Core 2.2 and need to design 3 tier architecture. How can I do it. My Project Structure as below In Web API Project.. public void ConfigureServices(IServiceCollection services) { services.AddDbContext<HrmsDbContext>(opt => opt.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); } In DAL (Library project, I have made my DBContext and provided connectionstring like below. Is there any better so that I had not provide connectionstring at two places? and