Die Suche ergab 34 Treffer

von m.hosseinian
19. Jul 2015 23:41
Forum: Archiv
Thema: Coding with Variance
Antworten: 14
Zugriffe: 4290

Re: Coding with Variance

I have a non-technique question. Do we need to draw class diagram for this question? I just want to make sure because the question states "Sketch two designs". Assuming this hint: You do not have to implement the sorting method, but indicate in a _comment_ where you use the comparison operation I w...
von m.hosseinian
18. Jul 2015 23:33
Forum: Archiv
Thema: Coding with Variance
Antworten: 14
Zugriffe: 4290

Re: Coding with Variance

Irrelevant, but here is my running code, maybe it clears better my itention. (however, I don't like it since, it is mutable. Due to the requirement of the question that we should sketch a _trait_!) trait SortableCollection[A] extends Seq[A] { var elems: Seq[A] def sort(compare: (A, A) => Boolean): S...
von m.hosseinian
18. Jul 2015 22:18
Forum: Archiv
Thema: Coding with Variance
Antworten: 14
Zugriffe: 4290

Re: Coding with Variance

Simply because it is explicitly mentioned: Assume that you have a _base_ class Collection[A] which is covariant in A ... This _base_ gives me enough clue that I have to extend from this Collection. Another suggestion is the name of asked trait "SortableCollection". I think that is because if you loo...
von m.hosseinian
18. Jul 2015 20:21
Forum: Archiv
Thema: Coding with Variance
Antworten: 14
Zugriffe: 4290

Re: Coding with Variance

What I cant see is that, why you pass a collection to the sort that then you have to care for type boundaries and stuff? Isn't it that, the usage would be something like :

Code: Alles auswählen

val c: SortableCollection[Int] = ...
...
val sortedC: SortableCollection[Int] = c.sort()
von m.hosseinian
18. Jul 2015 20:10
Forum: Archiv
Thema: Hiding the details
Antworten: 13
Zugriffe: 1264

Re: Hiding the details

Still, if you refer to the intents given for each DP, it's Adapter pattern that has the closest intent to this problem.
von m.hosseinian
18. Jul 2015 20:05
Forum: Archiv
Thema: SRP & ISP
Antworten: 3
Zugriffe: 920

Re: SRP & ISP

The situation is when, the SRP violating class implements its non-coherent methods defined in a polluted interface which serves multiple groups of clients, each group use coherent set of methods of the interface.
Too long yet, I hope it's a clear sentence. :-)
von m.hosseinian
18. Jul 2015 19:42
Forum: Archiv
Thema: Coding with Variance
Antworten: 14
Zugriffe: 4290

Re: Coding with Variance

So, could you upload your final answer to this question? mine is this: Template method: trait SortableCollection[+A] extends Collection[A] { def sort(): SortableCollection[A] = { //... // compair method is called here <= //... } def compair(index: Int): Boolean } Strategy: trait SortableCollection[+...
von m.hosseinian
15. Jul 2015 16:37
Forum: Archiv
Thema: Midterm exam: Variance
Antworten: 3
Zugriffe: 788

Re: Midterm exam: Variance

Thank you very much for your comprehensive answer.
So what are your choices among f1..f6 ?
I assume f6 is not the answer.
But, I remember I have chosen this in the exam and they have accepted.
I'm not pretty sure. That's originally why I put this question here.
von m.hosseinian
15. Jul 2015 12:23
Forum: Archiv
Thema: Midterm exam: Variance
Antworten: 3
Zugriffe: 788

Midterm exam: Variance

Hi everyone,

Can anyone please tell me about the answers to question 1-c ?
I remember I got full points from the first part but now that I am reviewing, I faced a problem.
Maybe, my memory doesn't help!

BR,
Moe
von m.hosseinian
11. Jul 2015 14:47
Forum: Archiv
Thema: REScala Iterate documentation / slides difference
Antworten: 8
Zugriffe: 903

Re: REScala Iterate documentation / slides difference

Maybe they're about some older versions... But still wrong and misleading. I, actually, took a look at the documentation when it made little sense to me the way it's described in the slides.
von m.hosseinian
11. Jul 2015 14:40
Forum: Archiv
Thema: REScala Iterate documentation / slides difference
Antworten: 8
Zugriffe: 903

Re: REScala Iterate documentation / slides difference

I assume the value of e is irrelevant, it is not passed as f's argument instead, the value of signal is passed. At the end of the f's execution, the value of s is updated to the return value of f and is used for subsequent iterates. As I said, the following snippet holds, I've tested it: var test: I...
von m.hosseinian
11. Jul 2015 14:17
Forum: Archiv
Thema: REScala Iterate documentation / slides difference
Antworten: 8
Zugriffe: 903

Re: REScala Iterate documentation / slides difference

few weeks ago I posted this: viewtopic.php?f=234&t=32573
but, got no reply :-(
von m.hosseinian
9. Jul 2015 19:58
Forum: Archiv
Thema: Reflections on the Visitor Structure
Antworten: 5
Zugriffe: 492

Re: Reflections on the Visitor Structure

you're welcome, actually the problem is related to type checking on compile time, because visit is not declared for abstract that otherwise in order to implement the feature for each element type you have to explicitly type check/type cast the argument which does not follow OCP principle. And you're...
von m.hosseinian
9. Jul 2015 19:40
Forum: Archiv
Thema: Reflections on the Visitor Structure
Antworten: 5
Zugriffe: 492

Re: Reflections on the Visitor Structure

actually I didn't see your design as Visitor's applicant. Then I changed it this way: public abstract class Pizza { public abstract void print(); public void accept(Visitor v) { v.visit(this); //<= } } class CheesePizza extends Pizza { @Override public void print() { PizzaPrintVistor pv = new PizzaP...
von m.hosseinian
9. Jul 2015 11:59
Forum: Archiv
Thema: Reflections on the Visitor Structure
Antworten: 5
Zugriffe: 492

Reflections on the Visitor Structure

"Can we move the implementation of accept higher up the Element hierarchy?" According to the answer on the slides: "No. The method that is called by `v.visit(this)` is determined at compile-time." But, I'm not so clear with this answer. Can anyone lighten me a little bit up with this, possibly with ...

Zur erweiterten Suche