Acceptable naming conventions for .NET applications [closed] - naming

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I am an old school programmer with a rich background in C and C++. I was never one for Microsoft, I used to use Turbo C and Borland C++.
I always used descriptive variables names, often fairly long names, and Hungarian notation.
I have forced myself to get away from Hungarian notation, but still have little remnants lingering in my naming. Please tell me if the following would be considered good naming.
// Variables
bool fResult; // Boolen used for return value
String strLastName; // A persons last name
List<String> listNames; // A list of names
int nIndex; // An index
I notice Microsoft likes really generic names, like e and obj. This just doesn't feel right to me.
Also, for class variables I have adopted the underscore prefix for the name, _strLastName, for example.

The majority of c# code I see generally follows these conventions:
member variable:
private string _firstName;
property:
public string FirstName {get;set;}
function and method argument:
public string WelcomeMessage(string firstName)
class:
public class Repository
interface:
public interface IRespository
local variable in a function:
var firstName = "Jahova";
However as pointed out above - it doesn't matter too much - as long as everyone agrees and you don't end up with 10 different styles in 1 code base...
Also, for what it's worth, MS guidance on use of Hungarian notation:
Do not use Hungarian notation.
http://msdn.microsoft.com/en-us/library/ms229045.aspx

To be honest, coding conventions are unique to each person, team, or organization. So, if you're working alone, then just find something you're comfortable with and stick with it.
If you're working in a team, then you and the other members of your team should agree on the coding conventions that you use.
If you work in a larger organization, then chances are that there are coding conventions that will be imposed upon you.

Related

Heuristics for splitting full names

Splitting a full name into first and last names is an unsolvable problem because names are really, really complicated. As a result, my model, which represents authors and other contributors to a book, includes both name and filingName fields, where filingName should usually be "Last, First" (for Western names).
However, as a convenience for my users, I'd like to have my app make a reasonable guess at the filing name when the user fills in the regular name. The user can edit the filing name if the guess is wrong, of course, but if I guess right, I'll have saved them some time. Currently I'm simply assuming the last space-separated "word" is the last name and moving it to the front with a comma:
NSMutableArray * parts = [self.name componentsSeparatedByCharactersInSet:NSCharacterSet.whitespaceCharacterSet].mutableCopy;
if(parts.count < 2) {
return self.name;
}
NSString * lastName = parts.lastObject;
[parts removeLastObject];
return [NSString stringWithFormat:#"%#, %#", lastName, [parts componentsJoinedByString:#" "]];
I can immediately think of one case where this will lead me astray: suffixes like "Jr". But I'm sure there are many others. Are there any good resources explaining common naming caveats, or good examples of code tackling this problem, that I can use to improve my heuristic? I'm using Objective-C on the Mac (in case there's some obscure corner of a framework that could help me), but I'm willing to learn from code written in any language.
This sort of question has been asked before, but most answers either focus on the mechanics of splitting apart a string, or devolve into "design your model differently". I am designing my model differently; I'm just looking to let the computer do most of my users' work for them.
As I said earlier, this code is mainly handling the names of authors and other contributors to books. Some of the specific ramifications of that include:
There should only be one name in name, because I support attaching multiple authors to a book.
Most names will not have titles, but professional titles like "Dr." could show up. Ideally these would be discarded, not treated as part of the first name.
The names will usually be of people, but could sometimes be of organizations. I'm perfectly willing to risk mangling organization names to get better person name handling.
I expect I will mostly be handling European names, although detecting the orthography of the name should not be difficult.
The code should not be particularly sensitive to the user's locale.
When you build a software system, there are always serious problems that consume a lot of time. I wouldn't get stucked with this because there is no worldwide naming conventions nor rules. I don't think asking the user to enter his/her filing name will be a bother, for they'll do it just once.
That seems to be the easier solution IMHO.

Difference between SharePoint Content Type and List Definition [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm watching some SharePoint 2010 training DVD's and the instructor has just introduced Content Types and List Definitions. I'm a bit lost. They both seem like List Templates to me. MSDN's explanations aren't terribly helpful. Can anyone explain the difference, or give me some examples where you would use each one?
Content types are a way of structuring your data. Documents for example can be organized by having a content type 'meeting report' or 'sales presentation'. Each content type defines the specific set of metadata that applies to that document type and potentially contains a template. That template can be an empty meeting report (Word document) for example.
A list definition is a blueprint for a list or library. Examples are a document library, a picture library, a discussion board, ... The list definition defines which content types (potentially multiple) are attached to the list/library upon creation (users can modify this later) and determines which list views are created by default.
Once you have customized a list/library, you can generate a list template from it for later re-use. You can think of this as a user-created list definition. (It's not really a definition, but the concept is pretty much the same.)

Handling unexpected features during sprint [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Our team is going to adopt scrum and agile technics.
We've got a product, which we develop for multiple customers. This customers supplied us with necessary requirements, so everithing is fine to adopt agile techinics.
But at some moment (for example during sprint), new customer apears, and he wants to get a demo of product slightly different from what we have now. This may be some new features or minor differences in behavior. And he wants to get this demo for example during the week. It is very important to show that our product supports this features (because otherwise he will address to our competitors), so we have to develop this features (may be partly) during the week.
How we must handle this sort of features with agile? Move them to current sprint backlog? Or split one team to two and create another sprint? Or may be there is another way?
I generally agree with jessehouwing's answer. If the problem you outline is uncommon, then what he has answered makes sense. IF this will be a common occurrence, sprinting may not be the answer you are looking for. A more flexible approach to this problem would be Kanban. In Kanban you work story by story instead of planning an entire sprint. This style works nicely for teams who have regularly changing priorities.
Scrum allows you to re-negotiate the sprint between the Product Owner and the Development team, so if this item is very very important, the PO can propose the team to swap out already planned, but not started, work of the same size.
Or when the amount of work will consume all time remaining in the sprint, the PO can cancel the current sprint and call for a new sprint, with these changes as the most important items. All undone work in the cancelled sprint should be considered lost.
If these kinds of mid-sprint-changes happen frequently, you might want to reserve some capacity to accommodate these types of requests. Just reduce the number of story points you'll take on during the sprint planning meeting. Or, depending on your current sprint length, you might want to reduce the number of days in a sprint to a week or something, that way you'll reduce the risk when these types of changes are required.

Which OTP (one-time password) algorithm do banks use on their password generator token? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Many banks offer some token devices in order to create passwords for one time usage. I wonder which OTP algorithm they use? Is it HOTP or TOTP?
As aiodintsov said, the answer cannot be generalized but the choice of technology really depends upon the bank. My guess is TOTP. But let me give a reason on the choice.
TOTP removes the need for client and server to stay in sync on the event counter by using a Unix timestamp instead. The algorithm allows the server to choose how far off an incoming timestamp it deems acceptable, in order to correct for clock drift.
When you receive an OTP from a bank, it will usually say that you should use that OTP within certain timelimit after which it will expire. If the banks use HOTP, the OTPs neednot expire after a time interval rather it will expire only after you place another request, incrementing the counter.
So, next time you receive a OTP which does not ask you to use it within a timelimit, be sure it is generated using HOTP.
They may use whatever they want, any hash function of their choice. Both HOTP and TOTP are used. see RFC 4226 and RFC 6238. I once had a test card with HOTP algorithm in complete accordance with RFC 4226 and could use it for authentication solution (the secret key was provided for the card).

Interview Question: What is a hashmap? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I was asked this in an interview: "Tell me everything you know about hashmaps."
I proceeded to do just that: it's a data structure with key-value pairs; a hash function is used to locate the element; how hash collisions can be resolved, etc.
After I was done, they asked: "OK, now explain everything you just said to a 5-year-old. You can't use technical terms, especially hashing and mapping."
I have to say it took me by surprise and I didn't give a good answer. How would you answer?
Rules. Kids know rules. Kids know that certain items belong in certain places. A HashMap is like a set of rules that say, given an item (your shoes, your favorite book, or your clothes) that there is a specific place that they should go (the shoe rack, the bookshelf, or the closet).
So if you want to know where to look for your shoes, you know to look in the shoe rack.
But wait: what happens if the shoe rack is already full? There are a few options.
1) For each item, there's a list of places you can try. Try putting them next to the door. But wait, there's something there already: where else can we put them? Try the closet. If we need to find our shoes, we follow the same list until we find them. (probing sequences)
2) Buy a bigger house, with a bigger shoe rack. (dynamic resizing)
3) Stack the shoes on top of the rack, ignoring the fact that it makes it a real pain to find the right pair, because we have to go through all of the shoes in the pile to find them. (chaining).
Lets take the big word book, or dictionary, and try to find the word zebra. We can easily guess that zebras will be near the end of the book, just like the letter "Z" is at the end of the alphabet. Now lets say that we can always find where the zebra is inside of the big word book. This is the way that we can quickly find zebras, or elephants, or any other type of thing we can think of in the big word book. Sometimes two words will be on the same page like apple and ant. We are sure which page we want to look at, but we aren't sure how close apple and ant are to each other until we get to the page. Sometimes apple and ant can be on the same page and sometimes they might not be, some big word books have bigger words.
That's how I would have done it.
Speaking as a parent, if I had to explain a hashmap to a 5-year-old, I'd say exactly what you said while waving around a chocolate cupcake.
Seriously, questions like this ought to mean "can you explain the concept in plain english", a good heuristic for how well you've internalized your understanding of it. Since it sounds like you get that, the question seems a bit silly.
The pieces of data the map holds can be looked up by some related information, much like how pages can be looked up by the words on them in the index of a book.
The key advantage to using a HashMap is that like an index in a book, it's much quicker to look up the page a word is on in the index than it would be to start searching page by page for that word.
(I'm giving you a serious answer because the interviewer might have been trying to see how well you can explain technical concepts to non-techies like project managers and customers. Maybe a hashmap directly isn't so useful, but it's probably as fair an indication as any of translation skills.)
You have a book of blank but numbered pages and a special decoder ring that generates a page number when a something is entered into it into it.
To assign a value:
You get a ID (key) and a message (value).
You put the ID into the special decoder ring and it spits out the page number.
Open your book to that page. If the ID is on the page, cross out the ID/message.
Now write the ID and message on the page. If there is already a one or more other IDs with messages just write the new one below it.
To retrieve a value:
You are given just an ID (key).
You put the ID into the special decoder ring and it spits out the page number.
Open your book to that page. If the ID is on the page, read the message (value) that follows it.

Resources