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
Code Exchange requires membership for participation - click to join
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 22 replies
  • Subscribers 47 subscribers
  • Views 798 views
  • Users 0 members are here
Related

find a good name for a C++ class

Jan Cumps
Jan Cumps 29 days 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 28 days ago +2
    Stepper_wReply altho McStepperFace is high on my list or Stepper_TalksTooMuch
  • kmikemoo
    kmikemoo 29 days 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 29 days ago +1
    How about "Stepper_with_benefits"
Parents
  • michaelkellett
    michaelkellett 28 days ago

    I try, reasonably hard, never to duplicate code. A good indication that you are at risk is when two functions want the same name - then, maybe, they should be the same function with an additional parameter.

    So rather than Stepper_blocking and Stepper_asynch how about Stepper and let the initialisation set the behaviour on demand ?

    (As I've mentioned - I don't use C++ so this may be  a silly suggestion !)

    MK

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • Jan Cumps
    Jan Cumps 28 days ago in reply to michaelkellett
    michaelkellett said:
    rather than Stepper_blocking and Stepper_asynch how about Stepper and let the initialisation set the behaviour on demand ?

    There is a design pattern for that: Factory Method. Unfortunately I still have to name that other class Slight smile

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • Jan Cumps
    Jan Cumps 28 days ago in reply to michaelkellett
    michaelkellett said:
    rather than Stepper_blocking and Stepper_asynch how about Stepper and let the initialisation set the behaviour on demand ?

    There is a design pattern for that: Factory Method. Unfortunately I still have to name that other class Slight smile

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
  • beacon_dave
    beacon_dave 28 days ago in reply to Jan Cumps

    Perhaps just use constructor overloading ?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Jan Cumps
    Jan Cumps 28 days ago in reply to beacon_dave

    That's already there - but it's not a riddle that needs solving. There is no source code needed to decide if you need a stepper engine with notification or not. Should be a designer's decision.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
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