element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Code Exchange
  • Technologies
  • More
Code Exchange
Forum find a good name for a C++ class
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Code Exchange to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 22 replies
  • Subscribers 47 subscribers
  • Views 1221 views
  • Users 0 members are here
Related

find a good name for a C++ class

Jan Cumps
Jan Cumps 3 months ago

I'm designing two classes, for a stepper motor project:

  • one can send commands to a stepper motor.
    Each command has the number of steps and direction
    Running the motor happens async. Once the first command is sent, the motor heads off, until all commands are done.
    I named it stepper

  • the other class does the same, but it can notify the caller when it has completed a command.
    I named it stepper_interrupt

I'm not happy with that second name. It doesn't show what the class does. It's named after how it does it. I don't like that.

Do you have a better name?

please don't call it Stepper McStepperFace

  • Sign in to reply
  • Cancel

Top Replies

  • robogary
    robogary 3 months ago +2
    Stepper_wReply altho McStepperFace is high on my list or Stepper_TalksTooMuch
  • kmikemoo
    kmikemoo 3 months ago +1
    Jan Cumps Oh my word! I just about fell out of my chair laughing at the Stepper McStepperFace!! Recommend stepper_wEOL. EOL = End Of Line. Could be End Of Run, Class, Script, Routine.... just a thought…
  • rsc
    rsc 3 months ago +1
    How about "Stepper_with_benefits"
Parents
  • Jan Cumps
    Jan Cumps 3 months ago

    If I listen to ChatGPT, this would be a possible naming schema:

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Jan Cumps
    Jan Cumps 3 months ago in reply to Jan Cumps

    class stepper_controller {
    public:
        stepper_controller(PIO pio, uint sm) : pio_(pio), sm_(sm) {}
        virtual ~stepper_controller() {}
        take_steps(count, reverse);
        set_delay(delay)
    // ...
    };
    
    class stepper_callback_controller : public stepper_controller {
    private:
    
        class interrupt_manager {
        public:        // if an object is currently handling a pio + sm combination, it will 
            static bool register_stepper(stepper_callback_controller * stepper, bool step) {
                // ... logic to be able to send PIO IRQ to correct object
            }
        // ...
        };   
    
    public:
        stepper_callback_controller(PIO pio, uint sm) : 
            stepper_controller(pio,sm), 
            commands_(0U),
            callback_(nullptr) {
            interrupt_manager::register_stepper(this, true);
        }
        virtual ~stepper_callback_controller() {
            interrupt_manager::register_stepper(this, false);
        }
        uint commands();
        void reset_commands();
        void on_complete_callback(handler);
        // ...
    };

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • Jan Cumps
    Jan Cumps 3 months ago in reply to Jan Cumps

    class stepper_controller {
    public:
        stepper_controller(PIO pio, uint sm) : pio_(pio), sm_(sm) {}
        virtual ~stepper_controller() {}
        take_steps(count, reverse);
        set_delay(delay)
    // ...
    };
    
    class stepper_callback_controller : public stepper_controller {
    private:
    
        class interrupt_manager {
        public:        // if an object is currently handling a pio + sm combination, it will 
            static bool register_stepper(stepper_callback_controller * stepper, bool step) {
                // ... logic to be able to send PIO IRQ to correct object
            }
        // ...
        };   
    
    public:
        stepper_callback_controller(PIO pio, uint sm) : 
            stepper_controller(pio,sm), 
            commands_(0U),
            callback_(nullptr) {
            interrupt_manager::register_stepper(this, true);
        }
        virtual ~stepper_callback_controller() {
            interrupt_manager::register_stepper(this, false);
        }
        uint commands();
        void reset_commands();
        void on_complete_callback(handler);
        // ...
    };

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube