“Is” prefix and “On” suffix as reasonable exceptions to a “non-hungarian” naming standard?

First, I believe I’ve seen this question discussed here before, but I cannot find it. My apologies if you do find it.

I’m starting a new project, and trying to figure out why IsResolved and/or ResolvedOn make more sense to me than Resolved. Obviously, when something is named “CompanyName” (for example), I’m fairly confident I’ll test it as a string. However, when I see “Resolved”, and I know the object it describes may not have a valid value for a resolution date, it bothers me that I have to inspect the type to determine how to test it: for undefined/null/etc. (as a date), or as a boolean value.

Is it reasonable to claim that Is and On typically do more than declare the variable type; they declare the intent? Or perhaps simply that it makes the code clearer for some other reason I’m not quite able to codify?

Arguing the other side, if I look at the type of Resolved, and see that it is a boolean, I will have my answer. Perhaps this is no different than knowing that I’ll need to inspect a “Feasibility” variable to determine if it is an int, enum, or something else. (Although perhaps just that means “Feasbility” would be a sub-optimal name also.) And regardless, in the case of “ResolvedOn”, I still have to inspect whether it is nullable to determine if I additionally need to inspect an “IsResolved” value. What is the point of the verbosity, encoding a second time in the variable name that which can be deduced from the type?

Please give me a hand understanding why Is[Property] and [Property]On make sense to me, although Hungarian in general does not. Or, explain why an exception like this wouldn’t make sense?

Note: I primarily work with SQL, C#, and JavaScript.

9

First of all, most of the allergic reactions to Hungarian notation stems from the fact that consistent application tends to result in very unnatural looking names. Occasional uses of prefixes or suffixes that suggest a certain type should not be considered to be Hungarian notation unless the name looks very forced.

What you are doing by using “IsResolved” or “ResolvedOn” instead of “Resolved” is disambiguating what information is conveyed by the name (i.e. what is represented by a class or object of that name, what does a thus-named function return).

To take a few more examples:

  • Company
  • CompanyName
  • Resolved
  • IsResolved
  • ResolvedOn

When reading code, “Resolved” would be the only one where I don’t have an idea what it would represent and I would need to look it up. Context makes a difference and I am not claiming I am always correct, but “Resolved” is the only name in that list where I would not be able to tell at a glance if it looks to be used correctly.

4

I’d say that neither of your examples actually involve hungarian notation, which is why you find them acceptable. blnResolved or dtResolved would be using hungarian notation. IsResolved and ResolvedOn are simply descriptive names. You could make IsResolved into HasBeenResolved if you like, but it’s considerably longer and will not convey any additional information.

That said, don’t let your dislike for hungarian notation get in the way of good names, DateResolved or ResolvedOnDate are again, just descriptive names. It just so happens that it includes what on some systems are an approximation of the data type — note that for TSQL 2000 it isn’t the exact data type as it doesn’t have a date datatype.

I’d say that Resolved is a boolean, as well as IsResolved. ResolvedOn could be a date.

However, one simply cannot depend on notation or name of a variable to determine its type, especially if one is going through someone else’s code. Imagine variables named in different language (we had an exchange student from Mexico, and she named all of her variables in Spanish). Also, there is a variable CompanyCode, for example. Can you tell whether it’s a string or an int?

2

I believe the reason you think Is[Xxxxxxx] makes sense to you is due to your proficiency with SQL. Microsoft SQL has several IsXxxxxxxxx functions that makes life very easy for its users.

Your exposure to Microsoft SQL’s IsXxxxxxxx type programming has shaped your thought process and you tend to lean toward using it outside of SQL. Why, because it does make sense. You probably question why other languages do not have similar built-in functions and you also probalby look to build similar IsXxxxxx functions when they are missing from the other languages you use.

I’m only speculating but your [Xxxxxxxx]On is probably just a natural progression of a similar thought to simplify properties that can either be On or Off.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật