design-principles

Design Patterns for Multithreading [closed]

和自甴很熟 提交于 2019-12-03 14:58:53
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . Multitasking seems to be a disaster at times when big projects crashes due to shared mutation of I would say shared resources are

Pipeline design pattern implementation

做~自己de王妃 提交于 2019-12-03 04:50:11
问题 This is a design question regarding the implementation of a Pipeline. The following is my naive implementation. Interface for individual steps/stages in the pipeline: public interface Step<T, U> { public U execute(T input); } Concrete implementations of steps/stages in pipeline: public class StepOne implements Step<Integer, Integer> { @Override public Integer execute(Integer input) { return input + 100; } } public class StepTwo implements Step<Integer, Integer> { @Override public Integer

Design Patterns for Multithreading [closed]

眉间皱痕 提交于 2019-12-03 04:43:38
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Multitasking seems to be a disaster at times when big projects crashes due to shared mutation of I would say shared resources are accessed by multiple threads. It becomes very difficult to debug and trace the origin of bug and what is causing it. It made me

Pipeline design pattern implementation

蹲街弑〆低调 提交于 2019-12-02 18:04:23
This is a design question regarding the implementation of a Pipeline. The following is my naive implementation. Interface for individual steps/stages in the pipeline: public interface Step<T, U> { public U execute(T input); } Concrete implementations of steps/stages in pipeline: public class StepOne implements Step<Integer, Integer> { @Override public Integer execute(Integer input) { return input + 100; } } public class StepTwo implements Step<Integer, Integer> { @Override public Integer execute(Integer input) { return input + 500; } } public class StepThree implements Step<Integer, String> {

Max number of Activities!

北战南征 提交于 2019-12-02 10:23:54
问题 Is there any design guideline on the number of Activities an application could have? If there is a limit, what would be the ideal number of Activities that can be bundled in an Android application. 回答1: There is IMO no such limit, typical application would have < 10 activities (screens). Do you plan something that would be highly above this number? 来源: https://stackoverflow.com/questions/3608347/max-number-of-activities

Objects Without Behaviour

亡梦爱人 提交于 2019-12-02 07:23:55
问题 I have a question related to general OOP than specific to a language. I was trying out a simple application (in java) and I was trying to model it like a real world scenario. While re-factoring I realized that I came up with a simple object that just has one member and an overridden equals and hashcode. My question is.... is it a bad oo practice to have such objects (references to blogs etc would be welcome) 回答1: Short answer : is it a bad oo practice to have such objects Not necessarily, but

Composite design pattern: how to pass results from one component into another?

妖精的绣舞 提交于 2019-12-02 02:35:20
问题 I have the following code: interface IService { void Execute(); } class ServiceA : IService { public void Execute() { ... } } class ServiceB : IService { public void Execute() { ... } } class ServiceComposite : IService { List<IService> _services = new List<IService>(); public ServiceComposite() { _services.Add(new ServiceA()); _services.Add(new ServiceB()); } public void Execute() { foreach (IService service in _services) { service.Execute(); } } } The problem is that ServiceB depends on

Composite design pattern: how to pass results from one component into another?

风格不统一 提交于 2019-12-02 00:20:11
I have the following code: interface IService { void Execute(); } class ServiceA : IService { public void Execute() { ... } } class ServiceB : IService { public void Execute() { ... } } class ServiceComposite : IService { List<IService> _services = new List<IService>(); public ServiceComposite() { _services.Add(new ServiceA()); _services.Add(new ServiceB()); } public void Execute() { foreach (IService service in _services) { service.Execute(); } } } The problem is that ServiceB depends on some results from ServiceA. My idea is to create container class for storing the results, then inject it

Calling the variable property directly vs getter/setters - OOP Design

℡╲_俬逩灬. 提交于 2019-12-01 15:47:38
I know this is probably subjective but I read this optimization page from Google for PHP and they suggest use the variable property directly without the need of getters and setters. Understandably I see the performance gain in this but is this really a good design practice to follow? Their Example using getter/setter: class dog { public $name = ''; public function setName($name) { $this->name = $name; } public function getName() { return $this->name; } } $rover = new dog(); $rover->setName('rover'); echo $rover->getName(); Suggested Optimization: $rover = new dog(); $rover->name = 'rover';

Calling the variable property directly vs getter/setters - OOP Design

笑着哭i 提交于 2019-12-01 13:53:52
问题 I know this is probably subjective but I read this optimization page from Google for PHP and they suggest use the variable property directly without the need of getters and setters. Understandably I see the performance gain in this but is this really a good design practice to follow? Their Example using getter/setter: class dog { public $name = ''; public function setName($name) { $this->name = $name; } public function getName() { return $this->name; } } $rover = new dog(); $rover->setName(