"Ian Collins" <ian-> wrote in message [64];
>
>>> float dollarsPerMonth;
>>>} EMPLOYEE;
>>>
>>>Verbose, but at least you don't have to look at the header to see what
>>>the members represent.
>>
>>
>> However that's probably a good idea in the long run. Personally I abhore
>> camel-back naming and/or overly long names, but that's just MO.
>
> I dislike overly long names, so the above structure would still be a
> smell to me. If the currency is important, make it a member. If you
> want the first and last names, make them members. So I would end up
> with something like
>
> typedef enum { Dollars, Peanuts } Currency;
> enum { Nnews:...> Christopher Layne
> wrote:
>> Ian Collins wrote:
>>
>>
>>>typedef struct
>>>{
>>> char firstnameLastnameameLength = 32 };
>
> typedef struct
> {
> char firstname[NameLength];
> char lastname[NameLength];
> Currency currency;
> float monthlySalary;
> } Employee;
>
> Clear, unambiguous and not overly long.
>
But lots of snags.
Firstly, it is probably better to have names stored as familair name,
surname, other intials. I'm sure that people who work with this type of data
have long since figured out standards. But you are not necessarily in
control. If other parts of the application require the name as a single
ASCIIZ string, then it is just going to be a nuisance to have endless
conversion routines.
Secodly, names ought to be short.
By accesseing everythign through an
Employee * employee;
you have already added a layer of complexity. The rule of two states that a
human-readable name can have two elements. So you've used your two with
employee->name;
employee->first_name is a parse job.
consider
strcpy(new_employee->first_name,
candiate_employees[result->success].first_name);
virtually unreadable, but all we are doing is copying over a field.
You might object that you can understand exactly what that line is doing,
without even working on the program. In isolation, yes, but when all the
lines in the program are like that, you soon have a mess.
|