# Question about OOP

**URL:** <https://discourse.processing.org/t/question-about-oop/5960>\
**Category:** Coding Questions\
**Created:** [November 26, 2018, 4:58pm UTC](https://discourse.processing.org/t/question-about-oop/5960 "2018-11-26T16:58:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vjjv](https://avatars.discourse-cdn.com/v4/letter/v/df705f/32.png) [@vjjv](https://discourse.processing.org/u/vjjv)\
**Post date:** [November 26, 2018, 4:58pm UTC](https://discourse.processing.org/t/question-about-oop/5960/1 "2018-11-26T16:58:10Z")

</div>

hello! i`ve a deep question: imagine that you have objects (maybe an ellipse) and differents behaviors (move up, down, left, rigth) what would be the best way to program in a OOP paradigm? using interfaces? i mean, i would like to apply some behavior to objects in differents moments, but i want to keep them in a separate class. Thanks!

---

<div class="post-metadata">

**Author:** ![Kevin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kevin/32/2297_2.png) [@Kevin](https://discourse.processing.org/u/Kevin)\
**Post date:** [November 27, 2018, 12:15am UTC](https://discourse.processing.org/t/question-about-oop/5960/2 "2018-11-27T00:15:42Z")

</div>

It really depends on exactly what you’re trying to do.

Also note that there is never a “best” way to program anything. It’s always about trade-offs and deciding what you care about most.

Can you please put together a simple example that shows what you’re trying to do?

You might find this thread interesting:

> [@How to determine right Class to use, if not equal to used variable's Class?](https://discourse.processing.org/t/how-to-determine-right-class-to-use-if-not-equal-to-used-variables-class/5940/4):
>
> Sounds like you might be looking for the [command pattern](https://en.wikipedia.org/wiki/Command_pattern)? Basically, you’d want to create a top-level interface like this: interface FoodAction{ void act(); } Then you’d create implementations of that interface for each behavior you want to model: class Raw implements FoodAction{ void act(){ println("is raw"); } } class Cooked implements FoodAction{ void act(){ println("is cooked"); } } Then you could use instances of FoodAction like this: class Banana{ ArrayList\<FoodA…
