software-design

Entity Identity - use of strings instead of type

空扰寡人 提交于 2019-12-07 16:24:28
I have seen a number of DDD posts and indeed books where entity classes are derived from some form of base class that has a generic parameter for the Entity Identity type: public interface IEntity<out TKey> { TKey Id { get; } } public interface IComplexEntity<out TKey, in TEntity> { TKey Id { get; } bool IsSameAs(TEntity entity); } //Object Definition public class TaxPayer : IComplexEntity<string, User> { ... } On Vernon's Implementing Domain Driven design, specific types are created for use as identities: public class TaxPayerIdentity : Identity { public TaxPayerIdentity() { } public

Decentralised user authentication — possible?

泪湿孤枕 提交于 2019-12-07 16:00:27
问题 I'm designing a fully distributed P2P messaging application. Edit: Not just any messaging application -- specifically a public forum. Messages are passed along from neighbour to neighbour, so messages may come in from a peer other than the original author. Secrecy of communication is unimportant. However, verification of the author of a message is vital. The problem needs an introduction: In client-server models, each client can be sure that messages' origins are what the message says they

VIPER - Should the Interactor return only the necessary information?

坚强是说给别人听的谎言 提交于 2019-12-06 15:40:51
问题 In the VIPER design pattern, should the Interactor return all the information that might be used by multiple presenter actions or should I have a separate struct for each one? In my case, I have a map that displays places. To display those places I need to retrieve a list of PlaceItem's from a PlacesInteractor which could have only a coordinate and a color (used to change the pin's head color) that would be transformed into a annotations by the presenter. Now lets say that when the user

Balancing Design Principles: Unit Testing

别说谁变了你拦得住时间么 提交于 2019-12-06 14:07:49
I am writing a simulation of Bananagrams. Currently, I have a GameMaster class that maintains the common collection of pieces. The deal(Player) method deals a certain number of pieces to that player. I want to write unit tests for this. However, at this point, I have no getters, and thus no way to check the status of the objects. Why not add getters? I don't want to add code to the public interface only for testing. Right now, there is no other reason to expose those functions. What am I supposed to do here? Add the getters anyway, cluttering the public API (or hoping that they will be needed

Simple factory and Factory Method Design pattern difference

三世轮回 提交于 2019-12-05 18:36:50
I am learning design patterns newly & I am trying to understand the difference between Simple Factory & Factory Method Pattern. First I want to clear that , I tried reading lot of articles from Stack-overflow and other sites regarding the same but that doesn't helped me. Here is my question: Lets consider I have a product hierarchy as shown below: I have written a simple Factory class as shown below public class SimpleItemFactory { static Item getItem(String type) { if(type.equals("Cake")) { return new Cake(); }else if(type.equals("Chocolate")) { return new Chocolate(); }else { return null; }

Code design: performance vs maintainability [closed]

心不动则不痛 提交于 2019-12-05 17:24:25
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 2 years ago . Contextualisation Im am implementing a bytecode instrumenter using the soot framework in a testing context and I want to know which design is better. I am building the TraceMethod object for every Method in a Class that I am instrumenting and I want to run this instrumenter on multiple Classes. Which Option offers more performance(Space–time)? Option 1: (Maps) public class

Passing optional parameters to @Query of a Spring Data Repository method

自闭症网瘾萝莉.ら 提交于 2019-12-05 10:58:52
I work with Spring Data and Neo4j in my current project and have the following situation: @RestController @RequestMapping(value = SearchResource.URI) public class PersonResource { public static final String URI = "/person"; @Autowired PersonRepository personRepository; @GetMapping public Collection<Person> findPersons( @RequestParam(value = "name", required = false) String name, @RequestParam(value = "birthDate", required = false) Long birthDate, @RequestParam(value = "town", required = false) Spring town) { Collection<Person> persons; if (name != null && birthDate == null && town == null) {

Is it a good practice to mock Automapper in unit tests?

别说谁变了你拦得住时间么 提交于 2019-12-05 09:14:41
There is this codebase where we use automapper and have 2 layers, Domain and Service . Each has its object for data representation, DomainItem and ServiceItem . The service gets data from domain, the uses constructor injected automapper instance to map class Service { public ServiceItem Get(int id) { var domainItem = this.domain.Get(id); return this.mapper.Map<DomainItem, ServiceItem>(domainItem); } } Assume best practices, so mapper has no side-effects and no external dependencies. You'd write a static function to convert one object to another within seconds, just mapping fields. With this in

Why doesn't JavaScript get its own thread in common browsers?

▼魔方 西西 提交于 2019-12-04 16:26:48
问题 Not enough that JavaScript isn't multithreaded, apparently JavaScript doesn't even get its own but shares a thread with a load of other stuff. Even in most modern browsers JavaScript is typically in the same queue as painting, updating styles, and handling user actions. Why is that? From my experience an immensely improved user experience could be gained if JavaScript ran on its own thread, alone by JS not blocking UI rendering or the liberation of intricate or limited message queue

Why are stored procedures still not supported in Rails (3+)?

假如想象 提交于 2019-12-04 11:24:18
问题 I am familiar with the long standing love-hate relationship between Ruby on Rails, DB(MS)-drivers and Stored Procedures and I have been developing Rails applications since version 2.3.2. However, every once in a while a situation arises where a SP is simply a better choice than combining data on the (much slower) application level. Specifically, running reports which combines data from multiple tables is usually better suited for a SP. Why are stored procedures still so poorly integrated into