software-design

How to build a class structure, when members are also structured hierarchically?

久未见 提交于 2019-12-20 17:40:40
问题 I'm building a PHP web application, that should provide to the user a possiblity to order an "installation"/setup of a (ConnectDirect or File Transfer Gateway) connection between him and another person/organization. (The technical specifica of the connection implementation are not important -- in the application it's only about the connections as product, that can be ordered and managed.) The classes hierarchy for its model layer should represent following real-world infrastructure: There are

Handling CSV files in C++

筅森魡賤 提交于 2019-12-20 06:47:25
问题 I have a requirement where i need to search product barcode from a csv file shown below. Sr. No.,Product Barcode,Product Description,Discount (%),Price Per Unit 1,011001,TOILET PAPER,5,40 2,011002,BATHING SOAP,0,27 3,011003,MOISTURIZER,3,95 4,011004,SHAMPOO,0,115 5,011005,CONDITIONER,5,155 6,011006,TISSUE,10,60 7,011007,HAIR OIL,0,75 8,011008,HAIR GEL,0,96 9,011009,BODY LOTION,7,195 10,011010,FACE WASH,0,85 When the user enters the barcode, it should search the csv file and should pick up the

can I use different two class diagrams for two different environments? [closed]

北城余情 提交于 2019-12-20 06:18:23
问题 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 . I'm working on project for two different environment which are iOS and Android, and it's so hared for me to design one class diagram for two different systems, so can I use two class diagrams, one for android and the other for iOS ? I mean it doesn't make any sense to use the

Can a use-case include and precondition the same other use-case?

为君一笑 提交于 2019-12-20 04:19:30
问题 Let's take the example of logging in and add item as two use case of an items management system. the requirements of the client are : (he needs/wants to : ) Gain legitimate access to the resources of the system; Add Item (create one). we also know that no unauthenticated user should use the system ! My questions are : 1) Is " Gain Access " a use case ? A precondition to other use-cases ? Or Both ? (knowing that by naming the use-case " Gain Access " and not "Logging in" I wanted to highlight

Passing managedObjectContext along to view/controller hierarchy

感情迁移 提交于 2019-12-20 02:56:32
问题 Managed object context in most cases created in application delegate. What are the ways of passing it along to view/controller hierarchy, so every navigation/tab controller in the tree can have access to it. Passing it every time from parent to child may not be the best since I have to carry this information every time and sometimes not all of the controllers to the way of particular child may need it. 回答1: The recommended design is to do a dependency injection. This means that when you

What happens when you initialize instance variables outside of __init__

落爺英雄遲暮 提交于 2019-12-19 07:39:24
问题 In python when you initialize an instance variable (e.g. self.my_var ) you should do it in your class __init__ function, so that the memory is properly reserved for this variable per instance ( <--my mistake, see bellow ). When you want to define class level variables you do it outside of a function and without the self prefix. What happens when you instantiate a variable inside a function other than the __init__ with the self prefix? It behaves like a normal instance variable, is there a

Adapter Pattern: Class Adapter vs Object Adapter

ぐ巨炮叔叔 提交于 2019-12-18 11:02:16
问题 I have a few questions about the Adapter pattern. I understand that the class adapter inherits from the adaptee while the object adapter has the adaptee as an object rather than inheriting from it. When would you use a class adapter over an object adapter and vice versa? Also, what are the trade-offs of using the class adapter and the trade-offs of the object adapter? 回答1: I can see one advantage for the object adapter, depending on your programming language: if the latter does not support

Twitter-like app using MongoDB

不问归期 提交于 2019-12-18 10:12:05
问题 I'm making an app that uses the classic "follow" mechanism (the one used by Twitter and a lot of other apps around the web). I'm using MongoDB. My system has a difference, though: an user can follow groups of users. That means that if you follow a group, you'll automatically follow all the users who are members of that group. Of course users can belong to more than one group. This is what I came up with: when user A follows user B , id of user B gets added to an embedded array (called

what is the difference between a view model and a data transfer object?

混江龙づ霸主 提交于 2019-12-18 10:05:31
问题 I'm basing this question on Fowler PoEAA. Given your familiarity with this text, aren't the ViewModels used in ASP.NET MVC the same as DTOs? Why or why not? Thank you. 回答1: They serve a similar purpose (encapsulating data for another layer of the application) but they do it differently and for different reasons. The purpose of a DTO is to reduce the number of calls between tiers of an application, especially when those calls are expensive (e.g. distributed systems). DTOs are almost always

Repository and Data Mapper pattern

百般思念 提交于 2019-12-17 15:26:10
问题 After a lots of read about Repository and Data Mapper I decided to implement those patterns in a test project. Since I'm new to these I'd like to get your views about how did I implement those in a simple project. Jeremy Miller says : Do some sort of nontrivial, personal coding project where you can freely experiment with design patterns. But I don't know I did all this things right or not. Here is my project structure : As you can see there are many folders which I'm going to describe them