Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8357861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:37:13+00:00 2026-06-09T10:37:13+00:00

I wrote a simple tag manager class in matlab, and I’m struggling (or maybe

  • 0

I wrote a simple tag manager class in matlab, and I’m struggling (or maybe over-thinking 😉 with naming my class methods appropriately. The class is called tag_manager. Here are my question regarding a clear API and implementation:

  • for adding a tag, should I call the method add or add_tag? same goes for removing.
  • for renaming a tag, should I call the method rename_tag or rename?

I always feel like adding the _tag suffix, so that it is clear what a method is acting upon.

  • nbr_tags is a counter that keep track on the number of tags that are currently stored. I sometimes need to access this number, and so instead of going through the list of tags and calculating the number of entries, I thought to return this value through a class method. Is return_nbr_tags the way to go, or could this be named more succinctly?
  • Very often, I need to know the index of a tag, which is in turn used to look up some elements in some other matrix. In order to prevent code to become to long, I called this method simply inx() which is supposed to be an abbreviation for return_tag_index. I’m aware that today I do know what inx() stands for, but in two weeks from now I’ll probably won’t be able to remember. So what is the best way of naming these kind of methods?

here’s the class definition:

properties (SetAccess = private, GetAccess = public)
    tag_names = {}; % store the tags
    tag_rel_indx = []; % the relative tag index
    tag_abs_indx = []; % the absolute tag index
end

properties (SetAccess = private, GetAccess = public, Hidden = true)
    nbr_tags = 0;
    abs_tag_counter = 0;
end

methods
    % add single tag to list. should be 'add' or 'add_tag'?
    function obj = add_tag(obj, name)
    end

    % remove single tag from list
    function obj = remove_tag(obj, name)
    end

    % short-cut for 'return_tag_index'
    function indx = inx(obj, name)
        indx = return_tag_index(obj, name);
    end

    % rename tag
    function obj = rename_tag(obj, old_name, new_name)
    end

    % re-order tags by name
    function obj = reorder_by_name(obj)
    end

    % return number of tags stored in tagmanager
    function nbr_tags = return_nbr_tags(obj)
        nbr_tags = obj.nbr_tags;
    end

end

Thanks a lot!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T10:37:16+00:00Added an answer on June 9, 2026 at 10:37 am

    There is always a trade-off between using highly explicit function names (which is really helpful to understand code) and creating code that’s easy to develop and use. If you need to make shortcut names for methods, it’s a sign that you have moved to far toward explicit function names.

    In your case, since you’re creating a tag manager, I would drop tag from the methods, and instead start the convention of instantiating your tag manager class as tags = tagManager;, such that the method of adding tags is written either tags.add(...) or add(tags,...). Adding more explicit method names will help, though, when you’re adding something other than tags, e.g. tags.addGroup. Your index method then becomes index(tags,name), which is, in my eyes, both short and clear.

    PS: Why have a returnNumberOfTags method? You can just read from the property, and add set/get methods if necessary.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote simple class that on the start it just increase the value of
So, I wrote a simple Ruby class, and put it in my rails /lib
i wrote simple 3 functions to scrape titles , description and keywords of simple
I wrote simple load testing tool for testing performance of Java modules. One problem
I wrote a simple XML file and a DTD file including an entity, but
I wrote a simple function, that makes emacs add matching quotes (so when I
I wrote a simple plugin which sets some css code using wp_options. It all
I wrote a simple test program for opencv to see if it's working after
I wrote a simple code to capture the netdevice notifications and simply print their
I wrote a simple C program: #include <unistd.h> #include <stdio.h> int main( int argc,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.