Skip to content

Should objects and methods be included in basics? #46

Closed

Description

@arm61

@bjmorgan raised the idea that the concept of objects having methods should be introduced immediately after functions, without necessarily explaining classes.

This issue is to chat about that.

Activity

  1. j-m-dean commented on Apr 2, 2020

    @j-m-dean
    Contributor

    Pros: It would make the optimisation section more readable as it would explain solution.x and solution.fun. , as well as, most likely, some of the good practice chapter. It is probably a nice thing just to mention. Build with exposure from examples in the good practise and data work sections and then property introduce it in the advanced chapter.

    Cons: Thinking of chemistry examples that do not introduce classes may be tricky. It may be too much, too fast for students and confuse them.

  2. arm61 commented on Apr 2, 2020

    @arm61
    ContributorAuthor

    A potential way round the first con would be to make a custom class that is like

    # in a file called elements.py
    
    class Carbon:
        def __init__(self):
            self.atomic_number = 6
            self.electrons = 6
        def ionise(ionisation):
            self.electrons += ionisation
    

    In the book the student would import elements then do like

    carbon = Carbon()
    carbon_anion = Carbon()
    carbon_anion.ionise(-1)
    
  3. RMeli commented on May 1, 2020

    @RMeli
    Contributor

    This is an interesting discussion. When I learned programming I followed C++ How to Program, where the authors introduce classes, objects, and member functions even before control statements and functions (see C++ How to Program - TOC). That was quite extreme (and I struggled with most concepts at first), but since most libraries are based on OOP, a short introduction inBasics might be beneficial. This will help to better understand simple things like mystring.upper() (already used in 1.1 Types) and myarray.shape (that will probably appear in 1.3 Numpy Arrays).

  4. arm61 commented on May 2, 2020

    @arm61
    ContributorAuthor

    I think there is definitely utility to introducing class methods, perhaps as "object methods" later in the Basics section.

    However, I think that introducing everything to do with classes is a bit over the top (and very C++ esc). Remember that the aim of the book is to give chemists the tool of programming for chemistry tasks, you don't need to be able to do OOP to fit a straight line to Arrhenius data and make a nice plot of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions