Jump to content

  • Log In with Google      Sign In   
  • Create Account

Álvaro

Member Since 07 Mar 2002
Offline Last Active Today, 04:13 PM

Posts I've Made

In Topic: Is using the Factory or Builder pattern nessesary?

Yesterday, 05:41 PM

There are no mandates in programming. Do whatever will make the code more clear. Using a factory or builder is an attempt at restricting what parts of the code need to know about the difference between Domestic and International.

But it looks like your design is doomed to begin with. How are the documents going to be used? Since the base class doesn't expose any virtual functions that may make use of them, you are probably going to be needing to know the type of client in some other part of the code.

I would personally add a variable to Client indicating whether it's international or domestic, and leave the list of documents empty for domestic clients.

Couldn't you argue that that breaks ISP? Pretty much breaks ISP verbatim actually.


I have a healthy disrespect for OOP rules. :)

If I understand correctly, you are complaining about Client having a list of documents which is not used in the case of domestic clients. If domestic clients having documents is something that doesn't make any sense, then I see your point. I would need to know more about the exact context in which this code is being written to make a judgement, but it seems to me it's more like "we don't currently have a use for the documents in the case of a domestic client", but that sounds like something that may change tomorrow.

In Topic: Is using the Factory or Builder pattern nessesary?

01 May 2016 - 05:59 PM

There are no mandates in programming. Do whatever will make the code more clear. Using a factory or builder is an attempt at restricting what parts of the code need to know about the difference between Domestic and International.

But it looks like your design is doomed to begin with. How are the documents going to be used? Since the base class doesn't expose any virtual functions that may make use of them, you are probably going to be needing to know the type of client in some other part of the code.

I would personally add a variable to Client indicating whether it's international or domestic, and leave the list of documents empty for domestic clients.

In Topic: Lagrange multiplier in constrained dynamics

27 April 2016 - 01:28 PM

I read parts of the tutorial and I think that way of thinking of Lagrange multipliers is probably very useful. The part you quoted about minimizing C seems wrong, though.

In Topic: Lagrange multiplier in constrained dynamics

27 April 2016 - 07:46 AM

I haven't clicked on the link to the tutorial, but I can explain how Lagrange multipliers work.

You want to minimize f(x,y) subject to g(x,y) = 0. We'll introduce an additional variable l (usually "lambda", but I don't have that letter available). Let's look at the function

L(x,y,l) = f(x,y) - l*g(x,y)

and imagine you've found a point where the derivative of L with respect to each of the three variables is 0. You then have

dL/dx = df/dx - l*dg/dx = 0
dL/dy = df/dy - l*dg/dx = 0
dL/dl = g(x,y) = 0

The last condition guarantees that the constraint is being satisfied. The other two basically say that the levels of f and g are tangent.

These are necessary conditions for a point (x,y) to be a solution to your problem. Sufficient conditions do exist, but they are a bit trickier to think about, and this may or may not be important in your case.

In Topic: AI and .net

25 April 2016 - 05:51 AM

https://en.wikipedia.org/wiki/Prolog
https://prolog.codeplex.com/


You are going to have a really hard time building something in Prolog that is robust enough to understand something like 'Does the dog alive?'.

PARTNERS