Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracy marlatt branch #2

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

TracyMarlatt
Copy link

No description provided.

Now extends abstract class Shape, and computes its own area and perimeter
Added a new triangle object to the array of shapes and compute aggregate perimeter
Shapes of class Shape (generalized) and calls the getArea() method for each shape
Extends Shape and computes its own area and perimeter
@TracyMarlatt
Copy link
Author

.Added Shape superclass and getArea methods to subclasses Rectangle, Circle and Triangle

@@ -0,0 +1,9 @@
package planForExtensionExercise;

public abstract class Shape {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this abstract class only has methods, it could be an interface instead of an abstract class. Tracy, can you comment on why you made it an abstract class instead of an interface?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used an abstract class largely because the relationship between Shape and
its subclasses is a very strong, hierarchical one so it seemed to make
sense from an interpretability standpoint. Also it is my understanding that
abstract classes are faster than interfaces and may be preferable in cases
where there is no obvious advantage to using an interface.

On Thu, Feb 5, 2015 at 11:11 AM, Spencer Robinson [email protected]
wrote:

In plan-for-extension-exercise/src/planForExtensionExercise/Shape.java
#2 (comment):

@@ -0,0 +1,9 @@
+package planForExtensionExercise;
+
+public abstract class Shape {

Because this abstract class only has methods, it could be an interface
instead of an abstract class. Tracy, can you comment on why you made it an
abstract class instead of an interface?


Reply to this email directly or view it on GitHub
https://github.com/siostechcorp/exercises/pull/2/files#r24173904.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Purely for the fun of it, will you please humor me by changing Shape to an interface?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

On Thu, Feb 5, 2015 at 11:33 AM, Spencer Robinson [email protected]
wrote:

In plan-for-extension-exercise/src/planForExtensionExercise/Shape.java
#2 (comment):

@@ -0,0 +1,9 @@
+package planForExtensionExercise;
+
+public abstract class Shape {

Purely for the fun of it, will you please humor me by changing Shape to an
interface?


Reply to this email directly or view it on GitHub
https://github.com/siostechcorp/exercises/pull/2/files#r24175858.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just created a pull request

On Thu, Feb 5, 2015 at 11:34 AM, Tracy Marlatt [email protected]
wrote:

Sure!

On Thu, Feb 5, 2015 at 11:33 AM, Spencer Robinson <
[email protected]> wrote:

In plan-for-extension-exercise/src/planForExtensionExercise/Shape.java
#2 (comment):

@@ -0,0 +1,9 @@
+package planForExtensionExercise;
+
+public abstract class Shape {

Purely for the fun of it, will you please humor me by changing Shape to
an interface?


Reply to this email directly or view it on GitHub
https://github.com/siostechcorp/exercises/pull/2/files#r24175858.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I wasn't very clear. Please update this pull request to include the change, and close the other pull request.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Spencer,

I updated my code in that branch and closed the newest pull request, but
how do I "update" my first pull request?

Thanks, Tracy

On Thu, Feb 5, 2015 at 11:48 AM, Spencer Robinson [email protected]
wrote:

In plan-for-extension-exercise/src/planForExtensionExercise/Shape.java
#2 (comment):

@@ -0,0 +1,9 @@
+package planForExtensionExercise;
+
+public abstract class Shape {

Sorry, I wasn't very clear. Please update this pull request to include the
change, and close the other pull request.


Reply to this email directly or view it on GitHub
https://github.com/siostechcorp/exercises/pull/2/files#r24177110.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just make a commit in the branch and the pull request will automatically be
updated.
On Feb 5, 2015 12:07 PM, "TracyMarlatt" [email protected] wrote:

In plan-for-extension-exercise/src/planForExtensionExercise/Shape.java
#2 (comment):

@@ -0,0 +1,9 @@
+package planForExtensionExercise;
+
+public abstract class Shape {

Hi Spencer, I updated my code in that branch and closed the newest pull
request, but how do I "update" my first pull request? Thanks, Tracy
… <#14b5ab621cca8ea0_>
On Thu, Feb 5, 2015 at 11:48 AM, Spencer Robinson <
[email protected]> wrote: In
plan-for-extension-exercise/src/planForExtensionExercise/Shape.java <
https://github.com/siostechcorp/exercises/pull/2#discussion_r24177110>: >
@@ -0,0 +1,9 @@ > +package planForExtensionExercise; > + > +public abstract
class Shape { Sorry, I wasn't very clear. Please update this pull request
to include the change, and close the other pull request. — Reply to this
email directly or view it on GitHub <
https://github.com/siostechcorp/exercises/pull/2/files#r24177110>.


Reply to this email directly or view it on GitHub
https://github.com/siostechcorp/exercises/pull/2/files#r24178946.

@srazin
Copy link

srazin commented Feb 5, 2015

Tracy, once you complete with the set of question with Spencer I would like to slightly extend this problem (perhaps that's what we will do for others as well). How would you approach that if you could not modify AreaCalculator? Use case is very much the same, but let's say AreaCalculator is a black box and handles the functionality that you know (calculating only certain shapes). You can not change the anything about AreaCaclulator but you want to extend its functionality (in anyway). You want to make sure that you are leveraging what the AreaCalculator has to offer (let's say it is very complex process and you don't not nor care about the internals) but also able to extend it for other functions that you may write in the future or objects. Let me know if you will have any questions?

@srazin
Copy link

srazin commented Feb 5, 2015

BTW perhaps we can keep that in a conversion vs the code changes. Perhaps you can describe how you would approach solving this issue.

Class implements Shape interface
Class implements Shape interface
Class implements Shape interface
Changed Shape to an interface
@TracyMarlatt
Copy link
Author

Then perhaps it is already done! The pull request shows four new commits. I
will work on addressing the latest question regarding the exercise, the
black box AreaCalculator. Thanks.

Please let me know if my changes are not reflected on your end...

On Thu, Feb 5, 2015 at 11:51 AM, Sergey A. Razin [email protected]
wrote:

BTW perhaps we can keep that in a conversion vs the code changes. Perhaps
you can describe how you would approach solving this issue.


Reply to this email directly or view it on GitHub
#2 (comment).

@TracyMarlatt
Copy link
Author

In your example, please let me clarify: I know that AreaCalculator computes
the aggregate area of all circles and rectangles, and I must utilize it to
do so, but build a framework around it to incorporate additional shapes?

On Thu, Feb 5, 2015 at 11:47 AM, Sergey A. Razin [email protected]
wrote:

Tracy, once you complete with the set of question with Spencer I would
like to slightly extend this problem (perhaps that's what we will do for
others as well). How would you approach that if you could not modify
AreaCalculator? Use case is very much the same, but let's say
AreaCalculator is a black box and handles the functionality that you know
(calculating only certain shapes). You can not change the anything about
AreaCaclulator but you want to extend its functionality (in anyway). You
want to make sure that you are leveraging what the AreaCalculator has to
offer (let's say it is very complex process and you don't not nor care
about the internals) but also able to extend it for other functions that
you may write in the future or objects. Let me know if you will have any
questions?


Reply to this email directly or view it on GitHub
#2 (comment).

@TracyMarlatt
Copy link
Author

Assuming that I understand your question, I believe I would approach the
solution as follows:

  • Create a new TotalAreaCalculator that subclasses AreaCalculator.
  • Provide a calculateArea method that can invoke
    AreaCalculator.calculateArea()
  • Assuming I don't know the inner workings of
    AreaCalculator.calculateArea(), I create two arrays, one with Circles and
    Rectangles, to be passed to the AreaCalculator.calculateArea(),
    and one to be processed by the subclass's calculateArea method.
  • If I knew anything about the inner workings of
    AreaCalculator.calculateArea(), I could pass the entire shapes array into
    AreaCalculator.calculateArea() without error, which would return the
    aggregate area of the Circles and Rectangles only, and then process the
    remainder of the shapes within the subclass method.
  • I would still want to facilitate future extensions of the code, so I
    would still create the Shape interface and have new shapes compute their
    own area (and other metrics) to minimize modifications of
    TotalAreaCalculator.

Does this approach properly address the situation you described, i.e., have
I correctly understood your question?

Thanks,
Tracy

On Thu, Feb 5, 2015 at 11:51 AM, Sergey A. Razin [email protected]
wrote:

BTW perhaps we can keep that in a conversion vs the code changes. Perhaps
you can describe how you would approach solving this issue.


Reply to this email directly or view it on GitHub
#2 (comment).

@srazin
Copy link

srazin commented Feb 5, 2015

Tracy, description certainly make sense however details are important.
Could you please implement the changes you have described?

"I create two arrays" - hint I do not believe you need an array, Keep in
mind you can change things around AreaCalculator.

Thank you!


Regards,
Sergey A. Razin, Ph.D.
Chief Technology Officer
http://www.us.sios.com/
SIOS Technology Corp. http://www.us.sios.comLeading Open Source and
Cloud Computing

Phone: (650) 669-8914
LinkedIn: http://www.linkedin.com/in/sergeyrazin
Meet me: http://www.meetme.so/TechDozor http://www.meetme.so/techdozor
Follow me: http://www.twitter.com/TechDozor
Read me: http://blog.techdozor.org
See you @ All Things Open http://www.allthingsopen.org
Please consider the environment before printing this message.

On Thu, Feb 5, 2015 at 12:52 PM, TracyMarlatt [email protected]
wrote:

Assuming that I understand your question, I believe I would approach the
solution as follows:

  • Create a new TotalAreaCalculator that subclasses AreaCalculator.
  • Provide a calculateArea method that can invoke
    AreaCalculator.calculateArea()
  • Assuming I don't know the inner workings of
    AreaCalculator.calculateArea(), I create two arrays, one with Circles and
    Rectangles, to be passed to the AreaCalculator.calculateArea(),
    and one to be processed by the subclass's calculateArea method.
  • If I knew anything about the inner workings of
    AreaCalculator.calculateArea(), I could pass the entire shapes array into
    AreaCalculator.calculateArea() without error, which would return the
    aggregate area of the Circles and Rectangles only, and then process the
    remainder of the shapes within the subclass method.
  • I would still want to facilitate future extensions of the code, so I
    would still create the Shape interface and have new shapes compute their
    own area (and other metrics) to minimize modifications of
    TotalAreaCalculator.

Does this approach properly address the situation you described, i.e., have
I correctly understood your question?

Thanks,
Tracy

On Thu, Feb 5, 2015 at 11:51 AM, Sergey A. Razin <[email protected]

wrote:

BTW perhaps we can keep that in a conversion vs the code changes. Perhaps
you can describe how you would approach solving this issue.


Reply to this email directly or view it on GitHub
<#2 (comment)
.


Reply to this email directly or view it on GitHub
#2 (comment).

@spencerhrob
Copy link
Contributor

To clarify Sergey's request:

Create a new branch of the repository and make the "new" version there, implementing the design you mentioned. Then make a pull request for that branch. (In this branch, assume that you cannot make any changes to the AreaCalculator.java file).

@TracyMarlatt
Copy link
Author

Will do, thank you!

On Thu, Feb 5, 2015 at 2:16 PM, Spencer Robinson [email protected]
wrote:

To clarify Sergey's request:

Create a new branch of the repository and make the "new" version there,
implementing the design you mentioned. Then make a pull request for that
branch.


Reply to this email directly or view it on GitHub
#2 (comment).

@TracyMarlatt
Copy link
Author

Hi Spencer,

I have added the new pull request, with an implementation of my proposed
solution to the problem. Thanks!

Tracy

On Thu, Feb 5, 2015 at 2:16 PM, Spencer Robinson [email protected]
wrote:

To clarify Sergey's request:

Create a new branch of the repository and make the "new" version there,
implementing the design you mentioned. Then make a pull request for that
branch.


Reply to this email directly or view it on GitHub
#2 (comment).

@TracyMarlatt
Copy link
Author

Hi Dr. Razin,

I have just submitted an implementation of my proposed solution. Thanks!

Best,
Tracy

On Thu, Feb 5, 2015 at 2:11 PM, Sergey A. Razin [email protected]
wrote:

Tracy, description certainly make sense however details are important.
Could you please implement the changes you have described?

"I create two arrays" - hint I do not believe you need an array, Keep in
mind you can change things around AreaCalculator.

Thank you!


Regards,
Sergey A. Razin, Ph.D.
Chief Technology Officer
http://www.us.sios.com/
SIOS Technology Corp. http://www.us.sios.comLeading Open Source and
Cloud Computing

Phone: (650) 669-8914
LinkedIn: http://www.linkedin.com/in/sergeyrazin
Meet me: http://www.meetme.so/TechDozor http://www.meetme.so/techdozor
Follow me: http://www.twitter.com/TechDozor
Read me: http://blog.techdozor.org
See you @ All Things Open http://www.allthingsopen.org
Please consider the environment before printing this message.

On Thu, Feb 5, 2015 at 12:52 PM, TracyMarlatt [email protected]
wrote:

Assuming that I understand your question, I believe I would approach the
solution as follows:

  • Create a new TotalAreaCalculator that subclasses AreaCalculator.
  • Provide a calculateArea method that can invoke
    AreaCalculator.calculateArea()
  • Assuming I don't know the inner workings of
    AreaCalculator.calculateArea(), I create two arrays, one with Circles and
    Rectangles, to be passed to the AreaCalculator.calculateArea(),
    and one to be processed by the subclass's calculateArea method.
  • If I knew anything about the inner workings of
    AreaCalculator.calculateArea(), I could pass the entire shapes array into
    AreaCalculator.calculateArea() without error, which would return the
    aggregate area of the Circles and Rectangles only, and then process the
    remainder of the shapes within the subclass method.
  • I would still want to facilitate future extensions of the code, so I
    would still create the Shape interface and have new shapes compute their
    own area (and other metrics) to minimize modifications of
    TotalAreaCalculator.

Does this approach properly address the situation you described, i.e.,
have
I correctly understood your question?

Thanks,
Tracy

On Thu, Feb 5, 2015 at 11:51 AM, Sergey A. Razin <
[email protected]

wrote:

BTW perhaps we can keep that in a conversion vs the code changes.
Perhaps
you can describe how you would approach solving this issue.


Reply to this email directly or view it on GitHub
<
#2 (comment)
.


Reply to this email directly or view it on GitHub
<#2 (comment)
.


Reply to this email directly or view it on GitHub
#2 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants