Another inconvenience of your solution is that: if you have N objective 
functions, you will have to define N types and cannot use loop. However, in 
my solution, I only need to construct an array of objective functions (as 
objects).


On Sunday, November 22, 2015 at 2:20:30 PM UTC+1, Sisyphuss wrote:
>
> I was waiting for someone others to comment on it. But since no one did 
> it, I'll try it.
>
> Your solution is just fine for personal use. But imagine that you are 
> making an application working on ObjectiveFunction. For your clients to 
> profit from your application, they should inherit a concrete type from your 
> abstract ObjectiveFunction. However, ObjectiveFunction gives no information 
> about how to construct a concrete subtype. All your clients know is that 
> they can use a "fancy call". All in all, for your clients, they have to 
> have knowledge of inheritance (a beginner won't be able to do it) and 
> perfect information of interface (should provide a detailed manual).
>
> Instead, my solution is more direct and flexible, Everyone looking into 
> the definition knows that all it needs is two functions. I can further use 
> constructor to regulate the initialization. Moreover, my object can work 
> with your type: `myObjectiveFunction.f = yourObjectiveFunction` and 
> `myObjectiveFunction.g = @D yourObjectiveFunction`.
>
>
>

Reply via email to