When should I create a class?

Asked

Viewed 488 times

0

I know it sounds like a really silly question, but I’m starting now in the world of programming (focused on mobile).

When I create an app it gets all the functions within the Activities, then I never know when I should take methods and attributes from the class and separate them. ah! this also serves to organize packages and classes

Grateful for the attention.

2 answers

2


Depends,

Each activity has its own life cycle, which may or may not affect the app’s own life cycle.

I recommend reading Activity.

And then there are fragments, which helps the app to be divided into blocks of the app itself, which you can then reuse in various activities. I recommend reading Fragment.

And then, following the Java standards, you should program following the POO paradigm, creating classes to represent various things (objects or abstract things)

  • Ow, thank you very much. By the way, some tip for those who are starting now?

  • I recommend reading certain Android Cookbook’s and seeing tutorials of basic things on android, how to start activities, etc.

  • Once again, thank you

0

Based on the concept that a classe is a structure that abstracts a set of objects with similar characteristics it can contain methods or attributes. So you can have a class to represent an entity of your bank for example or a class that contains methods to perform operations in your bank. Before you start coding I suggest you give a good read on a material about POO Object Orientation Concepts - Ufpa Object-Oriented Programming - Unicamp

Browser other questions tagged

You are not signed in. Login or sign up in order to post.