Skip to main content
Code Review

Return to Question

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

I created a new question with many of the recommended modifications, here: Simple object-oriented calculator - follow-up Simple object-oriented calculator - follow-up

I created a new question with many of the recommended modifications, here: Simple object-oriented calculator - follow-up

I created a new question with many of the recommended modifications, here: Simple object-oriented calculator - follow-up

added 136 characters in body
Source Link

Edit

I created a new question with many of the recommended modifications, here: Simple object-oriented calculator - follow-up

Edit

I created a new question with many of the recommended modifications, here: Simple object-oriented calculator - follow-up

Rollback to Revision 13
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

Object-Oriented Simple Calculatorobject-oriented calculator

After studying several ways of doing OOP in JavaScript I think I finally came up with one that seems OK to me. My question is: isIs it okay? Do you see some problems I can face by using OOP in JavaScript like this?

  • I can't do a call to a higher method version (I. I mean, call to a "grandfather" class's method that has already been overridden. Only to the last method version. I rarely do this, so I think it's okay.
  • Too different from what's normally done in JavaScript. Although, I'm really not sure about this one.

Any comments or criticisms welcomed.

Edit

The objective of this question isn't a code review of a simple calculator. I'm a senior developer and studing jsstudying JS for some time now and I develop in several other languages and FWs. You can take a look on other (more verbose) OOP methods I studied before in my blog's post here.

So I'm perfectly aware how an MVC works and what should be the function for each layer. I have done a simple calculator as an example to show how I intend to do JS OOP. I have mixed UI handling code and logic on purpose just to simplify the example. In a real system I would have separated it in different classes. That goes to the names also. In actual code I allways VERY verbose names.

Actually, the first name ofI'm perfectly aware how an MVC works and what should be the question was: "Is this way of doingfunction for each layer. I have done a simple calculator as an example to show how I intend to do JS OOP ok?". It was editedI have mixed UI handling code and as it's my first question here,logic on purpose just to simplify the example. In a real system I didn't wantwould have separated it in different classes. That goes to revert the editionnames also. In actual code I always use VERY verbose names.

This question's intention is present this oop format to other developers to see if it has any problems I'm not seeing. So I'm not worried with this specific task as it's a mere example. So in order to focus answers to this point, I ask the readers of this question and anyone who can possibly answer it to stick to problems this way of doing oop can have. If someone thinks it's ok I also would like to hear from you. :)

Nevertheless, thanksThis question's intention is present this OOP format to all who caredother developers to analysesee if it has any problems I'm not seeing.

Edit 2 So I'm not worried with this specific task as it's a mere example. In order to focus answers to this point, please stick to ways of doing this in OOP.

If someone thinks it's ok I created a new question with many of the recommended modifications, here: Simple object-oriented calculator - follow-up also would like to hear from you.

Object-Oriented Simple Calculator

After studying several ways of doing OOP in JavaScript I think I finally came up with one that seems OK to me. My question is: is it okay? Do you see some problems I can face by using OOP in JavaScript like this?

  • I can't do a call to a higher method version (I mean, call to a "grandfather" class's method that has already been overridden. Only to the last method version. I rarely do this, so I think it's okay.
  • Too different from what's normally done in JavaScript. Although, I'm really not sure about this one.

Any comments or criticisms welcomed.

Edit

The objective of this question isn't a code review of a simple calculator. I'm a senior developer and studing js for some time now and I develop in several other languages and FWs. You can take a look on other (more verbose) OOP methods I studied before in my blog's post here.

So I'm perfectly aware how an MVC works and what should be the function for each layer. I have done a simple calculator as an example to show how I intend to do JS OOP. I have mixed UI handling code and logic on purpose just to simplify the example. In a real system I would have separated it in different classes. That goes to the names also. In actual code I allways VERY verbose names.

Actually, the first name of the question was: "Is this way of doing JS OOP ok?". It was edited and as it's my first question here, I didn't want to revert the edition.

This question's intention is present this oop format to other developers to see if it has any problems I'm not seeing. So I'm not worried with this specific task as it's a mere example. So in order to focus answers to this point, I ask the readers of this question and anyone who can possibly answer it to stick to problems this way of doing oop can have. If someone thinks it's ok I also would like to hear from you. :)

Nevertheless, thanks to all who cared to analyse it.

Edit 2

I created a new question with many of the recommended modifications, here: Simple object-oriented calculator - follow-up

Simple object-oriented calculator

After studying several ways of doing OOP in JavaScript I think I finally came up with one that seems OK to me. Is it okay? Do you see some problems I can face by using OOP in JavaScript like this?

  • I can't do a call to a higher method version. I mean, call to a "grandfather" class's method that has already been overridden. Only to the last method version. I rarely do this, so I think it's okay.
  • Too different from what's normally done in JavaScript. Although, I'm really not sure about this one.

The objective of this question isn't a code review of a simple calculator. I'm a senior developer and studying JS for some time now and I develop in several other languages and FWs. You can take a look on other (more verbose) OOP methods I studied before in my blog's post here.

I'm perfectly aware how an MVC works and what should be the function for each layer. I have done a simple calculator as an example to show how I intend to do JS OOP. I have mixed UI handling code and logic on purpose just to simplify the example. In a real system I would have separated it in different classes. That goes to the names also. In actual code I always use VERY verbose names.

This question's intention is present this OOP format to other developers to see if it has any problems I'm not seeing. So I'm not worried with this specific task as it's a mere example. In order to focus answers to this point, please stick to ways of doing this in OOP.

If someone thinks it's ok I also would like to hear from you.

Rollback to Revision 12
Source Link
Loading
deleted 585 characters in body; edited title
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238
Loading
added 186 characters in body
Source Link
Loading
Rollback to Revision 9
Source Link
Flambino
  • 33.3k
  • 2
  • 46
  • 90
Loading
Included new code modified based on answer's recommendations
Source Link
Loading
added 177 characters in body
Source Link
Loading
deleted 2 characters in body
Source Link
Loading
Explained my intentions
Source Link
Loading
Tweeted twitter.com/StackCodeReview/status/680055751956672513
edited tags
Link
200_success
  • 145.6k
  • 22
  • 190
  • 479
Loading
added 59 characters in body
Source Link
SirPython
  • 13.5k
  • 3
  • 38
  • 93
Loading
added 899 characters in body
Source Link
Loading
Converted example into Stack Snippet
Source Link
Loading
deleted 121 characters in body
Source Link
Mathieu Guindon
  • 75.5k
  • 18
  • 194
  • 467
Loading
Source Link
Loading
default

AltStyle によって変換されたページ (->オリジナル) /