software-design

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

戏子无情 提交于 2019-11-29 20:14:53
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. 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 trivially serializable, and almost never contain any behaviour. For example, you're developing an e-Commerce

Is it a bad practice to use jQuery in Angular? [closed]

走远了吗. 提交于 2019-11-29 14:01:24
My question is the following. Should I avoid using any kind of jQuery code in Angular application as it seems legit to have only one thing interacting with DOM. Another question is if anyone came across problems where he couldn't find any other solution but writing a quick hack with jQuery. Thank YOU! Yes it's a bad practice, but sometimes it will save you much time, especially when you are looking for a plugin, Do it when necessary only, and keep a note to switch it back when other solutions are available. The first thing you should do is to read this thread on SO "Thinking in AngularJS" if I

the significance of java RMI please? [closed]

跟風遠走 提交于 2019-11-29 03:18:07
Why do people use RMI, or when should I use RMI? I read those tutorials about RMI on oracle's website.But it doesn't provides enough practical examples. To my understanding, a software should have its modules as "unrelated and separated" as possible. RMI somehow seems to be an example of high coupling to me. Why is this not a bad coding practice? I thought the client should only fire instructions,whereas all the actually manipulations of the object were done by the server. (I am currently working towards a computer science bachelor degree and very inexperienced, so please correct me if I

Is it a bad practice to use jQuery in Angular? [closed]

一曲冷凌霜 提交于 2019-11-28 07:37:33
问题 My question is the following. Should I avoid using any kind of jQuery code in Angular application as it seems legit to have only one thing interacting with DOM. Another question is if anyone came across problems where he couldn't find any other solution but writing a quick hack with jQuery. Thank YOU! 回答1: Yes it's a bad practice, but sometimes it will save you much time, especially when you are looking for a plugin, Do it when necessary only, and keep a note to switch it back when other

Using shared_ptr for unique ownership (kind of) - is this good practice?

时光总嘲笑我的痴心妄想 提交于 2019-11-28 06:14:51
问题 this is quite hard to explain but I'll try my best. So, I have a RenderComponent, EventManager and RenderSystem. In my RenderComponents constructor, I raise a renderComponentCreated event which the RenderSystem subscribes to. Using an event args object, I pass a RenderNode as data which contains the information the renderSystem needs to draw the thing (drawable, position and type). So far so good. Now, when the renderComponent is deleted, I want the RenderNode to be removed from the

Clean Architecture - Robert Martin - How to connect use cases

ぐ巨炮叔叔 提交于 2019-11-28 06:03:58
I'm trying to implement the Clean Architecture described by Robert Martin. More specifically I'm using VIPER which is an iOS version of Clean Architecture. The problem I have is as follows: The user starts looking at a map with places (pins) on it. If he clicks a button, a pin is dropped and he is taken to another view to create (or edit if it was a click to an existent pin) the place (or cancel). In this other view, the user can edit the place's information and then click "back" or "done" (or "edit"). If he clicks "done", the PlaceDetailsViewController sends a message to the

How do I choose heap allocation vs. stack allocation in C++?

柔情痞子 提交于 2019-11-27 21:18:46
One of the C++ features that sets it apart from other languages is the ability to allocate complex objects as member variables or local variables instead of always having to allocate them with new . But this then leads to the question of which to choose in any given situation. Is there some good set of criteria for choosing how to allocate variables? When should I declare a member variable as a straight variable instead of as a reference or a pointer? When should I allocate a variable with new rather than use a local variable that's allocated on the stack? One of the C++ features that sets it

Is it the best practice to extract an interface for every class?

拈花ヽ惹草 提交于 2019-11-27 18:28:27
I have seen code where every class has an interface that it implements. Sometimes there is no common interface for them all. They are just there and they are used instead of concrete objects. They do not offer a generic interface for two classes and are specific to the domain of the problem that the class solves. Is there any reason to do that? After revisiting this answer, I've decided to amend it slightly. No, it's not best practice to extract interfaces for every class. This can actually be counterproductive. However, interfaces are useful for a few reasons: Test support (mocks, stubs).

Encapsulation vs Data Hiding - Java

跟風遠走 提交于 2019-11-27 17:17:34
Interviewer: What is encapsulation and how do you achieve it in Java? Me: Encapsulation is a mechanism to hide information from the client. The information may be data or implementation or algorithm. We achieve this using access modifiers. Interviewer: This is data hiding. How do we achieve encapsulation in Java? Me : uummmm Concrete Question: Other than 'Access Modifiers', what is the way to implement Encapsulation in Java? More generally encapsulation refers simply to bundling the data (e.g. of an object) with the operations on that data. So you have a class encapsulating data - fields -

Repository and Data Mapper pattern

▼魔方 西西 提交于 2019-11-27 16:57:14
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 in detail in below. Domain : Project Domain Entities go here I've a simple Personnel class which is