|
Hi,
Thank you for the blog link.
You propose what is called mixin, which is really the go to solution to avoid bloated inheritance hierarchies.
The good thing about mixin of Subject is that you hide functionality and avoids to duplicate the code in Subject.
The bad thing is that you still need to duplicate the code that calls Subject aka relaying.
DI with mixin is also good since you make the dependency known to the outside. This opens up for implementation replacement from the outside and gives better transparency.
However, Uncle Bob really wants to hide stuff and use inheritance to avoid ANY code duplication and he can't do that in a single inheritance language.
I love interfaces because they form a specification layer without any implementation details. I love abstract classes because they can be implementation templates for concrete classes. I do not want to mix the 2 concerns - at all. And it IS a tad annoying when you need add mixin in you abstract classes to avoid code duplication.
I wouldn't mind multiple inheritance, if the language/compiler could manage diamonds in a consistent and obvious way (No, C++ doesn't). The class hierarchy is however implementation - not specification (IMHO). Uncle Bob doesn't address that view on the interface keyword.... and I am not sure the interface keyword had that view in mind when invented.
|
|
|
|
|
Keld Ølykke wrote: No, C++ doesn't I think it does. Why do you say it doesn't?
Keld Ølykke wrote: class hierarchy is however implementation - not specification Agreed. Hence, I don't think interfaces are "harmful", but what Uncle Bob was really complaining about is not being able to have multiple base classes.
However, I think true separation of concerns would use neither DI nor inheritance to do his observer pattern but rather a separate "observer manager" class that does both the observing and registration/deregistration.
#SupportHeForShe If your actions inspire others to dream more, learn more, do more and become more, you are a leader.-John Q. Adams
You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
Only 2 things are infinite, the universe and human stupidity, and I'm not sure about the former.-Albert Einstein
|
|
|
|
|
Well, by not consistent I mean that you can end up with compiler accepted code, but it is unknown what it will do. The "dreaded diamond" refers to the situation where class C inherits from 2 classes B1 & B2 that both inherits the same base A. C will have 2 copies of all fields from A and at runtime it is undefined which copy you address.
|
|
|
|
|
Ah, sure, I see. But you can solve that by using "virtual" inheritance. Then there's only one instance of A. Of course, you can't always do that when using third-party libraries.
#SupportHeForShe If your actions inspire others to dream more, learn more, do more and become more, you are a leader.-John Q. Adams
You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
Only 2 things are infinite, the universe and human stupidity, and I'm not sure about the former.-Albert Einstein
|
|
|
|
|
Yes. If C++ was a game I would call it a tad unforgiving
|
|
|
|
|
this question is logical type. there is single data centre with single firewall and to handle 5 lakh clients from this single data centre i want a technique in which i dont have to mess any thing with data centre but infact some kind of delay must be generated at clients side only in order to avoid load or traffic on data centre
|
|
|
|
|
Impossible. How can client systems know when to delay and when it is OK to connect? If your system cannot be tuned to handle large load then you need to employ a network engineer to help you.
|
|
|
|
|
Can somebody explains how I can implement properly Open/Close principles in Python? Since Python class does not supports method overloading or function overloading like in C++, C# or Java. In. e.x.:
if I created class which calls connectivity:
class Connectivity(object):
def connect(self, ip, port):
and later If i want to add connection time out argument for connection method I cannot keep Open/Close principles like this:
class Connectivity(object):
def connect(self, ip, port):
def connect(self, ip, port, timeout):
So what I should do in this case? How I can follow properly SOLID principles in Python? Thank you in advance.
|
|
|
|
|
Disclaimer; I have never touched Python.
If C# had no function overloading I'd be passing an object, as opposed to a list of parameters. For example;
class ConnectArgs
{
public object self { get; set; }
public string ip { get; set; }
public int port { get; set; }
}
class ConnectArgsExt: ConnectArgs
{
public int TimeOut { get; set; }
}
With the method accepting it like below;
public connect(ConnectArgs args)
Since you defined a class, I assume Python has classes and supports inheritance. That way you needn't change the interface, but you'd still have the option to extend it with a new parameter if required.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
You need to create a new method with a different name, or, better still, a new class that inherits from this class. You can then override the method, but still call the base method if necessary. Something like:
class Connectivity(object):
def connect(self, ip, port):
class NewConnectivity(Connectivity):
def connect(self, ip, port, timeout):
Connectivity(self, ip, port)
|
|
|
|
|
Of course, the simplest way is to add the timeout as an optional parameter thus:
class Connectivity(object):
def connect(self, ip, port, timeout = 0):
x = Connectivity()
x.connect(ip, port)
x.connect(ip, port, 30)
|
|
|
|
|
i dont know anything about programming or designs but i want them to make a system in short it accepts documents PDF or word doc from various companies and they all arrive at our server, currently we are now manually selecting then printing each page, so my question is what technologies needed to make the process of making the arrived documents to be auto printed then saved in a database and then each document gets our company stamp on top of each paper + we want each document to have different barcode different serial number then the other documents. am doing the process manually on photoshop taking the company stamp and placing it on top of each paper but we didnt do the barcode method yet
|
|
|
|
|
Whay you posted is an explanation. Maybe not a very detailed one, but details would distract from the general idea you're conveying.
I'd first recommend to divide this into multiple (!) smaller projects; it'll be easier to handle. Receiving documents and putting them into a database should be relative easy. Stamping each document will be a lot harder - there's some readonly formats, and a password-protected Word file might be hard to modify. If the files are in a database, then another application can fetch those (independently of the rest of the apps) and prnt them (once!).
There's a four-part series on Joel that can help with creating specs[^].
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
If you're explaining the requirements to your developers then you don't need to worry about the details of implementation. Let them worry about that. What you need to do is document in as much detail as you can, and as clearly as you can, what you need the application to do. Think in terms of inputs and outputs.
Once you have documented your requirements, then pass this document to your development team to implement.
"There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." - C.A.R. Hoare
Home | LinkedIn | Google+ | Twitter
|
|
|
|
|
Member 11331225 wrote: How can i explain this to our programmers?
Just like you did. They would/should then ask you questions to clarify it.
For starters how exactly does the following happen "accepts documents PDF or word doc from various companies".
Member 11331225 wrote: and then each document gets our company stamp on top of each paper
Just to be clear...that sounds a bit suspect in terms of copyright. If the documents are originating from another company then you are bound by their terms of usage. You don't get to arbitrarily alter them unless it is within acceptable usage parameters. Not saying that you can't do this just why.
Might also note that this requirement - adding something to each page is going to make the project more complex.
And why do you need to print them at all?
|
|
|
|
|
I am currently working on a store search function. The search criteria are quite complex, for example:
Footage >= 50 AND (SizeCode == SizeType.Large OR MobileEnd == "ABC")
I think that each criterion could be represented by a Func<store, boot> (I am using C# and LINQ).
Func<Store, bool> filter1 = (s => s.Footage >= 50);
Func<Store, bool> filter2 = (s => s.MobileEnd =="abc");
Func<Store, bool> filter3 = (s => s.SizeCode == SizeType.Large);
My question is how I can deal with AND, OR, NOT logic, and order of precedence. How can I convert the user input into a LINQ expression?
Thanks.
|
|
|
|
|
|
Scott Guthrie[^] has a solution and there's an article on the subject[^].
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi all,
Any suggestion or tips on application architecture if i need to develop a server application which is using to communicate with remote machine?
(remark : machine firmware is using ROS.)
Original idea:
a) Client UI (.aspx) <---request/response---> web server(IIS) & db <---communicate via network connection---> machine
b) robot will keep update status to db via web server application every few second.
c) Meanwhile, server application need to do some algorithm then response to robot every few second or any instruction from robot.
d) Client need to connect to server every second to get the latest data (monitoring purpose)
e) Client can control robot via server application.
My question are,
1) shall i develop the server application using web technology or using window programming? (I found some article said that can using websocket .NET 4.5 as server,is suit for my case? )
2) what is the pro and con for both web and window programming?
Any tips or suggestions are welcome
Thanks in advance
wls
modified 17-Dec-14 12:47pm.
|
|
|
|
|
cocoonwls wrote: what is the pro and con for both web and window programming? That's a general question, not limited to your project. A webapp requires a webserver, a windows app a desktop. With a desktop app you know the user, in a webapp you can have multiple. Webapps have no access to local resources, local apps do.
cocoonwls wrote: 1) shall i develop the server application using web technology or using window
programming? I'd recommend diving into their tutorials first.
Looks[^] like ROS runs under a 'nix system, meaning that the harder part is making the call from the robot.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi, thank you for your response.
Actually making the call from robot was done by team member (via wifi protocol). Now i need to build a server application to handler/receive multiple request from robot.
I am now researching on <websockets with="" httphandler="" &="" javascript="">.Am i in the right track?
Note: My final output is allow user to control the robot via client application which is develop by using HTML5,jqery,javascript and asp.net with C# (idealy)
Regards.
|
|
|
|
|
cocoonwls wrote: Actually making the call from robot was done by team member (via wifi protocol). Yup, sounds like TCP/IP, but that does not answer whether the robot will be pushing/reading from a socket, or is expecting a webpage. You'd need to ask the team-member.
cocoonwls wrote: I am now researching on websockets .Am i in the right track Depends on what the team-member says, but I'd expect that it'd be the right track.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Quote: Yup, sounds like TCP/IP, but that does not answer whether the robot will be pushing/reading from a socket, or is expecting a webpage. You'd need to ask the team-member.
The robot will keep sending request to server (handshaking with server) , thus most of the time the server application will be in listening mode. Unless there have certain command need to robot take action, then server application will send a command via socket (robot have their own API).
Okay, now i am quite clear what should i do but one more things. For the server application, i need to response a webpage to client, so do i need to separate the server application ? what i mean is one server application do for serve robot, and another one do for client.My client need to monitor all the robot information on-time (update each 1 to 3 second).
Thanks again
|
|
|
|
|
That will depend on how your teammate will have implemented it on his side. You should ask if he/she can actually communicate using webpages (does the robot have a server where you can request pages from?)
A socket would be simpeler, as you'd open it and wait for a text to arrive
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Quote: A socket would be simpeler, as you'd open it and wait for a text to arrive Smile |
Okay, i think i will continue in websocket solution which is able to communicate with ROS
This is my last question, shall i develop the websocket as a window service or just host in IIS?
Thanks in advance
|
|
|
|
|