software-design

Circular dependency with the relationships “contains” and “is in”

本小妞迷上赌 提交于 2019-12-22 13:52:46
问题 I would like to gather opinion from you about the following problem. We have a class called "Room". Each room may contain zero or more instances of a class "Person", so the Room stores a collection of Persons (e.g. vector). It owns them. However, there is some time-consuming logic related to moving Persons between Rooms, so the Person also contains current Room they are in. It is just a pointer without ownership . This information is theoretically redundant, because one could derive it from

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

早过忘川 提交于 2019-12-22 07:47:06
问题 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

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

陌路散爱 提交于 2019-12-22 05:27:13
问题 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

Analysis and Design for Functional Programming [closed]

房东的猫 提交于 2019-12-22 04:14:23
问题 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 7 years ago . How do you deal with analysis and design phases when you plan to develop a system using a functional programming language like Haskell

How to apply composition in android MVP?

喜夏-厌秋 提交于 2019-12-21 09:17:33
问题 Recently I took over an android project which is built on top of MVP. While simple screens are quite straight forward and easy to read and maintain, the more complex parts of the app are not. Multiple inheritance levels have caused me days of switching between classes, trying to find out how the information flow is actually working. Here one example of the more problematic hierarchies: Since we use MVP, naturally there is another presenter class and another view class for each of the classes

CoreBluetooth: How to design code for many characteristics (30 - 40)?

泪湿孤枕 提交于 2019-12-21 04:13:23
问题 I searched around a bit and just found this as a possible duplicate question: Multiple CBPeripheral's for same device My problem is: I have multiple services which all together have about 30-40 characteristics (Yes, I need all of them...). As starting point for dealing with CoreBluetooth I always used the Apple Sample Code (CoreBluetooth Temperature Sensor). Discovery and Service/Characteristic handling is divided into two classes and this works fine for just a few characteristics. But

CoreBluetooth: How to design code for many characteristics (30 - 40)?

倾然丶 夕夏残阳落幕 提交于 2019-12-21 04:13:12
问题 I searched around a bit and just found this as a possible duplicate question: Multiple CBPeripheral's for same device My problem is: I have multiple services which all together have about 30-40 characteristics (Yes, I need all of them...). As starting point for dealing with CoreBluetooth I always used the Apple Sample Code (CoreBluetooth Temperature Sensor). Discovery and Service/Characteristic handling is divided into two classes and this works fine for just a few characteristics. But

Why prefer template method over dependency injection?

不羁岁月 提交于 2019-12-21 04:12:19
问题 I've been reading Design Patterns, by Gamma et al. I have a question concerning the Template Method as compared to Dependency Injection. With Template Method, you "template" classes with policies that provide alternatives for needed actions or calculations. So rather than choosing one policy from several alternatives and coding that policy into the class, you allow the user of the class to specify the alternative they want to use. It all sounds very reasonable to me. But I hit a bit of a

What are some good books for learning about software design/architechure? [closed]

喜你入骨 提交于 2019-12-21 02:41:37
问题 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 9 years ago . Not a book that talks about how to code but more high level organization of software. 回答1: General Responsibility Assignment Software

What's the best way to resolve a combinatorial explosion of interactions?

为君一笑 提交于 2019-12-20 19:39:45
问题 One of the things I'm working on right now has some similarities to a game. For purposes of illustration, I'm going to explain my problem using an example drawn from a fictitious, hypothetical game. Let's call it DeathBlaster 4: The Deathening . In DB4, you have a number of Ship objects which periodically and randomly encounter Phenomena as they travel. A given Phenomenon may have zero, one, or more Effects on a Ship that encounters it. For example, we might have four kinds of Ships and three