software-design

adapter-Any real example of Adapter Pattern

扶醉桌前 提交于 2019-12-17 10:10:10
问题 I want to demonstrate use of Adapter Pattern to my team. I've read many books and articles online. Everyone is citing an example which are useful to understand the concept (Shape, Memory Card, Electronic Adapter etc.), but there is no real case study. Can you please share any case study of Adapter Pattern? p.s. I tried searching existing questions on stackoverflow, but did not find the answer so posting it as a new question. If you know there's already an answer for this, then please redirect

Utility classes are evil? [closed]

房东的猫 提交于 2019-12-17 08:04:10
问题 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 last year . I saw this thread If a "Utilities" class is evil, where do I put my generic code? and thought why are utility classes evil? Lets say I have a domain model that is dozens of classes deep. I need to be able to xml-ify instances. Do I make a toXml method on the parent? Do I make a

Discussion: Which design patterns would you use for this solution?

社会主义新天地 提交于 2019-12-13 17:26:05
问题 I would like to design software that has the following solution: Products have features. Each products has rules for features: Product must have features a,b and d . _ Product must have at least x of list of features f,g and m _ Each feature of product has a weight. At runtime I'd like to create products using, from external input (file/user input) and add features to the product with rules . I'd like ask each product , given the features it's been fed, what score it has and what's missing.

What is Property Accessor Recursion in C#?

扶醉桌前 提交于 2019-12-13 03:39:45
问题 What is Property Accessor Recursion in C#? I see articles of how to resolve it, but want a pure technical definition of what it is. Resources on how to resolve it: c# property setter body without declaring a class-level property variable 回答1: It becomes clearer if you think of the getters and setters as methods (they really are methods in the background - C# just hides that from you). Whenever you retrieve the value of a property, you are calling the get method Whenever you set the value of a

How can I identify declarations and references to external classes and methods within a java program?

ぃ、小莉子 提交于 2019-12-13 00:24:49
问题 Suppose I have two packages(package1,package2) with one class in each package(package1.A, package2.B). I need to identify references from package1.A to package2.B and vice versa using a java program, and also references to any methods in each class as well. The code would be something like this: package package1; public class A{ public A(){ Class<?> clazz = Class.forName("package2.B"); Method mthd = clazz.getMethod("someMethod", Integer.TYPE); } public static void main(String[] args) { new A(

Best practice for enforcing type safety in polymorphic inheritance hierarchies [closed]

大憨熊 提交于 2019-12-12 15:49:32
问题 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 last year . I seem to run into this situation quite a lot and have yet to find a solution that I find acceptable. Quite often I will have parallel inheritance hierarchies where a method in one hierarchy gets passed the matching class from the other hierarchy as a parameter. Here is an

where in class hierarchy should instance methods be written?

自作多情 提交于 2019-12-12 12:07:50
问题 Here's a part of a class "hierarchy" that I use for a simulation model (my code is in Python, but I think my question isn't language dependent): class World: # highest-level class, which "knows" everything about the model # most likely will have just one instance # contains (e.g., in a dictionary) references to all the instances of class Agent class Agent: # each instance represents an agent # an agent can, among other things, move around according to certain rules # movement depends on the

How do you handle validation in composite microservice request?

陌路散爱 提交于 2019-12-12 11:20:12
问题 Consider an application with two entities: User (contains basic user data, such as name) Passport (contains authentication credentials, i.e. password) And two internal microservices: UserService (responsible for creating and managing users and their basic data) AuthService (responsible for user authentication and password handling) The User entity belongs to the UserService and Passport entity belongs to the AuthService . Those two services should be separated, because they solve very

Efficient design for a auto refresh mobile app

荒凉一梦 提交于 2019-12-12 11:20:09
问题 I was presented this problem few days back. Requirement was to design a mobile app which serves sports content to the user (say soccer). The app will allow the user to subscriber to specific team. Based on user's team selection, the apps serves only content related to that team on the user's home screen. Of course user has option to see content for all teams (via menu options). Special focus was on how would the content on user's home screen get refreshed automatically and should also take

Two java libraries importing each other?

…衆ロ難τιáo~ 提交于 2019-12-12 09:44:46
问题 I am working on a legacy framework and apparently there are two libraries, which are inter-dependent. By that I mean libA import from libB , and libB import from libA . First i think it is a terrible design, but why would somebody do something like this? Rather which conditions can lead somebody to write this ? edit: Each library depends on classes in the other, so they do import packages and have the other library jar in their build path. 回答1: It's easier to do in this case, because the two