473,799 Members | 3,276 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

give me some tips

"No newline at the end of your output" is really a problem? I've never
learned that before.
So I desire to know some tips about writting a program perfectly.Can
anyone give me some tips which are hardly learned from textbook or
easily ignored?
Thank you very much.

Mar 12 '06
28 3336

"Michael Mair" <Mi**********@i nvalid.invalid> wrote in message
news:47******** ****@individual .net...
Rod Pemberton schrieb:
"Yuri CHUANG" <yu*******@126. com> wrote in message
news:11******** **************@ i39g2000cwa.goo glegroups.com.. .

I'd start by learning how to solve some problems and write some programs
well. After solving and implementing
a few problems, you'll know whether you are better at "top-down" or
"bottoms-up" design. Each person has a
biological preference for each one (FYI, those who prefer "top-down" are N, and "bottoms-up" are S, in Myers-Briggs personality Type Indicator).


Hmmm, and what am I if I prefer one approach for some kinds of problems
and the other for other kinds of problems and the
midlevel-to-up-and-down and the come-from-top-and-bottom for yet
other classes of problems?


For the MBTI, X is used when an individual is balanced between the two
categories. Most people show a dominance for one category or the other.

But, you bring up a very good point: people's preference or natural
abilities can interfere with solving specific problems since certain
problems can only be solved when started from a certain point. Frequently,
both "top-down" and "bottoms up" programmers start having problems
"in-the-middle". The "top-down" programmer didn't allow for any special
cases (too generic) and has problems implementing the details, and the
"bottoms up" programmer has too much unnecessary detail and can't grasp the
"big-picture."
RP
Mar 12 '06 #11
"Rod Pemberton" <do*********@so rry.bitbucket.c mm> writes:
[...]
The following are my opinions for the C language are really are _specific_
to _my_ programming style. Others may not
have problems with the same areas of C that I do, so they probably have
their own list of issues. You'll need to develop
your own list of "problem areas" over time:
[...] 7) avoid the use of type qualifiers (const, volatile, restrict), except
where necessary, because they can hide programming errors
I don't see how "const" in particular can hide programming errors.

Use type qualifiers whenever they're appropriate. (restrict is
complex and seldom necessary; don't worry about it until you know what
you're doing. restrict is also new in C99, so many compilers don't
support it.)
8) avoid the use malloc(), except for dynamic data, because it leads to
memory allocation errors
What else would you use malloc() for?

Corollary: avoid the use of any feature X, because it leads to X
errors.

Better advice: use malloc() carefully.
9) typedef structs and give them file scope (i.e., "global"), it can simply
certain problems


Typedefs for structs are usually unnecessary. You can just declare

struct foo {
...
};

and refer to the type as "struct foo"; there's no real need to use a
typedef to create a second name for the type. (This is a somewhat
controversial point; many programmers prefer to be able to refer to
the type using a single identifier.)

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Mar 12 '06 #12
On 2006-03-12, Keith Thompson <ks***@mib.or g> wrote:
9) typedef structs and give them file scope (i.e., "global"), it can simply
certain problems


Typedefs for structs are usually unnecessary. You can just declare

struct foo {
...
};

and refer to the type as "struct foo"; there's no real need to use a
typedef to create a second name for the type. (This is a somewhat
controversial point; many programmers prefer to be able to refer to
the type using a single identifier.)


I'm glad this came up : personally I like the more "in your face"
robustness of this as opposed to using the typedef. There seems to be
just something "wrong" about the whole struct definition in
conjunction with typedef : I cant quite place what it is, although if
you look at the two examples below I think this is what has sometimes
led me astray in an "at a glance" read of strange code:

typedef struct point {
int x;
int y;
} Dot;

struct point {
int x;
int y;
} upperLeft;
Could only be me, but I like to see (in C) the struct keyword at the
point of instantiation.
Mar 12 '06 #13
On 2006-03-12, Yuri CHUANG <yu*******@126. com> wrote:
"No newline at the end of your output" is really a problem? I've never
learned that before.
So I desire to know some tips about writting a program perfectly.Can
anyone give me some tips which are hardly learned from textbook or
easily ignored?
Thank you very much.


Just reading some of the replies which may or may not have got tied ip
on "\n" at the end of each output:

Take a look at the exit(EXIT_SUCCE SS) function. Its a start to
understanding some issues/considerations when leaving a program.
Mar 12 '06 #14

"Richard G. Riley" <rg****@gmail.c om> wrote in message
news:47******** ****@individual .net...
On 2006-03-12, Keith Thompson <ks***@mib.or g> wrote:
9) typedef structs and give them file scope (i.e., "global"), it can simply certain problems


Typedefs for structs are usually unnecessary. You can just declare

struct foo {
...
};

and refer to the type as "struct foo"; there's no real need to use a
typedef to create a second name for the type. (This is a somewhat
controversial point; many programmers prefer to be able to refer to
the type using a single identifier.)


I'm glad this came up : personally I like the more "in your face"
robustness of this as opposed to using the typedef. There seems to be
just something "wrong" about the whole struct definition in
conjunction with typedef : I cant quite place what it is, although if
you look at the two examples below I think this is what has sometimes
led me astray in an "at a glance" read of strange code:

typedef struct point {
int x;
int y;
} Dot;

struct point {
int x;
int y;
} upperLeft;
Could only be me, but I like to see (in C) the struct keyword at the
point of instantiation.


Usually, there is no need for tye type-definition, i.e., 'point', in the
structure declaration when using a typedef:

typedef struct {
int x;
int y;
} Dot;

/*...*/

/*...some function...*/
{
Dot dot_x1y1,dot_x2 y2;
}

This has been beaten to death on other threads which was why I posted
"The following are my opinions for the C language ... are _specific_
to _my_ programming style," but Keith ignored...

RP

Mar 12 '06 #15

"Michael Mair" <Mi**********@i nvalid.invalid> wrote in message
news:47******** ****@individual .net...
Rod Pemberton schrieb:
"Yuri CHUANG" <yu*******@126. com> wrote in message
news:11******** **************@ i39g2000cwa.goo glegroups.com.. .
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.


Although there are a number of "Michael Mair" 's, that leads me to:

Professor (FH) Magister Michael Mair of FH-Modul, University of Innsbruck,
and MCI Innsbruck, Wien(Vienna), Austria.

Is that you? I'll assume that it is for the rest of this post.

Which translates roughly as having a PHD and/or Masters with a university of
applied sciences. I'm sure I botched that. But, since your English is very
good for an Austrian, I'll let you correct that. All of which led to two
pictures: one on FH-Modul and one on FH-Wien. Nice ties. FH-Modul appears
to be a tourism and hospitality university (Fachhochschuls tudiengänge für
tourismus-management).

You've mentioned teaching in your other posts. Assuming I've got the
correct person: "Doc", what exactly are you degreed in? Tourism management?
Rod Pemberton
Mar 12 '06 #16
Rod Pemberton schrieb:
"Michael Mair" <Mi**********@i nvalid.invalid> wrote in message
news:47******** ****@individual .net...
Rod Pemberton schrieb:
"Yuri CHUANG" <yu*******@126. com> wrote in message
news:11***** *************** **@i39g2000cwa. googlegroups.co m...

Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.

Although there are a number of "Michael Mair" 's, that leads me to:

Professor (FH) Magister Michael Mair of FH-Modul, University of Innsbruck,
and MCI Innsbruck, Wien(Vienna), Austria.

Is that you? I'll assume that it is for the rest of this post.


No, that is not me.
I have a University Diploma in "Technomathemat ik" which essentially is
maths sprinkled with computer science and one engineering discipline.
In my case that is engineering mechanics but I also had a look into
electrical engineering. This course appealed to me because you get
to understand the respective "languages" and are open to specialize
as you feel like.
I did some research in numerical mathematics (simulation and
optimization of dynamic mechanical systems) afterwards, in the course
of which I also gave a C course to relieve other people at our chair
and in order to have students who actually learnt the basics of C so
that we could hire them. In addition, I like teaching as it helps me
learn the stuff I thought I knew that much better.

Right now, I am working in an area where I need knowledge about
compiler construction and discrete mathematics -- an area I am more
enamoured with than numerical mathematics.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Mar 12 '06 #17

"Michael Mair" <Mi**********@i nvalid.invalid> wrote in message
news:47******** ****@individual .net...
Rod Pemberton schrieb:
"Michael Mair" <Mi**********@i nvalid.invalid> wrote in message
news:47******** ****@individual .net...
Rod Pemberton schrieb:
"Yuri CHUANG" <yu*******@126. com> wrote in message
news:11***** *************** **@i39g2000cwa. googlegroups.co m...
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.

Although there are a number of "Michael Mair" 's, that leads me to:

Professor (FH) Magister Michael Mair of FH-Modul, University of Innsbruck, and MCI Innsbruck, Wien(Vienna), Austria.

Is that you? I'll assume that it is for the rest of this post.


No, that is not me.


Darn, and thanks for not taking any offense. :-) Hopefully, it was a cheap
thrill. I found at least five "Rod Pemberton" 's in the US. I could
understand that one was black (must have been a Pemberton slave owner).
But, it was interesting to find a Vietnamese individual with that name! Go
figure...
I have a University Diploma in "Technomathemat ik" which essentially is
maths sprinkled with computer science and one engineering discipline.
In my case that is engineering mechanics but I also had a look into
electrical engineering. This course appealed to me because you get
to understand the respective "languages" and are open to specialize
as you feel like.
Ah, okay, I thought you seemed a bit more like an EE than a CS.
I did some research in numerical mathematics (simulation and
optimization of dynamic mechanical systems) afterwards, in the course
of which I also gave a C course to relieve other people at our chair
and in order to have students who actually learnt the basics of C so
that we could hire them.
"who actually learnt the basics of C"

I find that comment humorous. I knew quite a few degreed CS majors who
couldn't program. Of course, I knew a few EE who didn't know what an
electron was either...
In addition, I like teaching as it helps me
learn the stuff I thought I knew that much better.

Right now, I am working in an area where I need knowledge about
compiler construction and discrete mathematics -- an area I am more
enamoured with than numerical mathematics.


"compiler construction"

Yes, not coming from a CS background. I could _really_ use a huge amount of
good public information in this area. I've found stuff at a PHD level and
or ideas which perhaps are patented. I can't use information like that. I
need things like: whether it's easier to use stacks or binary trees. How to
identify when to use an optimization in the compiler backend. Is it better
to use tokens (abstract syntax tree) or string processing of text (concrete
syntax tree)? I could really use Necula's et. al. CIL (C Intermediate
Language) if it only had a flex and bison grammar...
Rod Pemberton

Mar 12 '06 #18
Rod Pemberton schrieb:
"Michael Mair" <Mi**********@i nvalid.invalid> wrote in message
news:47******** ****@individual .net...
in the course
of which I also gave a C course to relieve other people at our chair
and in order to have students who actually learnt the basics of C so
that we could hire them.
"who actually learnt the basics of C"

I find that comment humorous. I knew quite a few degreed CS majors who
couldn't program. Of course, I knew a few EE who didn't know what an
electron was either...


There was nothing humorous at the time. We even considered
banning applicants from a certain information technology
course for our job offers as they made up ninety percent of
the applications (with the shiniest certificates) and about
three percent of the knowledge.

Right now, I am working in an area where I need knowledge about
compiler construction and discrete mathematics -- an area I am more
enamoured with than numerical mathematics.


"compiler construction"


I am not sure whether this is the correct translation.
Essentially, whatever you can learn from the Dragon Book or
Muchnick's book.
Yes, not coming from a CS background. I could _really_ use a huge amount of
good public information in this area. I've found stuff at a PHD level and
or ideas which perhaps are patented. I can't use information like that. I
need things like: whether it's easier to use stacks or binary trees. How to
identify when to use an optimization in the compiler backend. Is it better
to use tokens (abstract syntax tree) or string processing of text (concrete
syntax tree)? I could really use Necula's et. al. CIL (C Intermediate
Language) if it only had a flex and bison grammar...


Some of the en.wikipedia.or g pages are a decent starting point
if it comes to basic concepts.

Apart from that: Have a look at graph theory; there is much nice
stuff on the web and, as discrete maths goes, it is a fun subject
as you can state really deep problems on a sheet of paper within
five minutes so that everyone understands the problem but the
proof took a hundred years to be found and conversely can prove
things in an easily understandable way. If you understand graph
theory and get an intermediate representation of some code, you
are ready to do general (not target specific) optimisations.

I am not actually writing a traditional compiler but am involved
in the optimisation of an intermediate representation of code;
the output of the product is C.
More about that only via PM and only as far as I am allowed to
tell about it.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Mar 12 '06 #19

"Michael Mair" <Mi**********@i nvalid.invalid> wrote in message
news:47******** ****@individual .net...
Rod Pemberton schrieb:
"Michael Mair" <Mi**********@i nvalid.invalid> wrote in message
news:47******** ****@individual .net...
There was nothing humorous at the time. We even considered
banning applicants from a certain information technology
course for our job offers as they made up ninety percent of
the applications (with the shiniest certificates) and about
three percent of the knowledge.
Right now, I am working in an area where I need knowledge about
compiler construction and discrete mathematics -- an area I am more
enamoured with than numerical mathematics.


"compiler construction"


I am not sure whether this is the correct translation.
Essentially, whatever you can learn from the Dragon Book or
Muchnick's book.


I've not heard of these, but will look.
Yes, not coming from a CS background. I could _really_ use a huge amount of good public information in this area. I've found stuff at a PHD level and or ideas which perhaps are patented. I can't use information like that. I need things like: whether it's easier to use stacks or binary trees. How to identify when to use an optimization in the compiler backend. Is it better to use tokens (abstract syntax tree) or string processing of text (concrete syntax tree)? I could really use Necula's et. al. CIL (C Intermediate
Language) if it only had a flex and bison grammar...


Apart from that: Have a look at graph theory; there is much nice
stuff on the web and, as discrete maths goes, it is a fun subject
as you can state really deep problems on a sheet of paper within
five minutes so that everyone understands the problem but the
proof took a hundred years to be found and conversely can prove
things in an easily understandable way. If you understand graph
theory and get an intermediate representation of some code, you
are ready to do general (not target specific) optimisations.


Hmm, graph theory. I'll _definately_ have a look at this. It'll probably
be a big time saver for me since my spatial relationship abilities are
(supposedly) off the charts.
I am not actually writing a traditional compiler but am involved
in the optimisation of an intermediate representation of code;
the output of the product is C.
More about that only via PM and only as far as I am allowed to
tell about it.


Well, you don't have to talk about that. I'm sure you've looked at other
stuff like:

GCC's RTL
TenDRA's ANDF
LCC's DAGs
Necula's CIL

So far, the only "C" compiler I've found that uses both a yacc and lex
grammar is Lutz Hamel's "C Subset Compiler" WCC for VMS.
Rod Pemberton
Mar 12 '06 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1865
by: arthur-e | last post by:
A new Machine was set up by our IS department - it came with Office Pro 2003. Access97, Word97 and Excel 97 were added. I'm trying to update an Access 97database to 2003 but get weird compiling errors - Date, Format and Left give errors. I've registered the missing (or those ocx's) that were indicated as missing- iincluding - mscomct2.ocx - and the date picker showed up but
7
2155
by: MLH | last post by:
?2944*24 gives me an overflow error, entered in the immediate window. Anybody else?
0
1045
by: mike | last post by:
Recently I posted a message about deploying an application over a network. I had the .net framework installed on the pcs, the local intranet set to full trust, and I had copied the bin directory to the production location. However, I didn't have any trouble running the program on any pcs that had visual studio 2003 installed on it. So, there was no problem with any development machines. However, some non-development machines would run the...
44
4198
by: Christoph Zwerschke | last post by:
In Python, it is possible to multiply a string with a number: >>> "hello"*3 'hellohellohello' However, you can't multiply a string with another string: >>> 'hello'*'world' Traceback (most recent call last): File "<interactive input>", line 1, in ?
2
1571
by: Lauren Wilson | last post by:
Hi Folks, We have a user who is suddenly getting the following error message when they start our very mature application. Other users of the same version are NOT getting this error: "Error 3075 - Function is not available in expressions in query expression 'Trim(!)' " I believe that this function comes from the DAO 3.6 library.
1
2105
by: Ellen12c | last post by:
On the last post I asked about a code to make a vertical scroll bar and ends up I didn't need one. I was told by a big group of people on this forum that I needed to do away with all the flash and the backgrounds to make the web site more conservative. I received post to let members know so they can go and give me tips and more help to make the web sit better. So I'm finished the new web site it took me 2 days to make it....
5
1223
by: Shanthagomathi | last post by:
can u pl give me some java1.5 tips which should be useful for projects..it can be general also Thanks
10
2152
by: sara | last post by:
Hi - I have a report that is 14 columnar sub-reports (Line up: Position- holders in each of our 14 locations - Manager, Assistant Manager, Receiving, Office, etc). I output directly to PDF (using ConvertReportToPDF from this site - Stephan Lebans) The formatting - Outlines on some fields - do not appear on subreports
0
1240
by: zzzmail.01 | last post by:
I find some useful tips about C/C++ and want to share with you. Sorry if it bothers you. Tips for better Coding Style: http://tmh-coding-tips.blogspot.com/2008/09/cc-guidelines-for-better-coding-style.html Tips for better Memory Management: http://tmh-coding-tips.blogspot.com/2008/09/cc-tips-for-better-memory-management.html Tips for Performance Enhancements
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10228
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9072
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7565
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.