473,769 Members | 4,846 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to actually write a program?

Hello there,
I have been on and off learning to code (with python being the second
language I have worked on after a bit of BASIC). What I really want to know
is, if you are going to actually write a program or a project of some sort,
how do you actually start.

Picture this, you know what you want the program to do (its features), you
have a possably rough idea of how the program will work. You have opened an
empty text file and saved it as 'mykewlprogram. py' and now your sitting in
front of an empty text file... Now then.... where do I start.

Any ideas about this problem :-)

Ta
Nick
Jul 18 '05
33 3492
> Any ideas about this problem :-)

I dont' know if this is a 'right' approach, but if the program has user
interface, it helps also first to create this user interface. That way
you'll be able to visualize what information your program needs to get
and to send back. It can be easier then to define classes and
methods...

Ksenia.
Jul 18 '05 #11
"Nick Evans" <ni**@huff.org. uk> writes:
Hello there,
I have been on and off learning to code (with python being the second
language I have worked on after a bit of BASIC). What I really want to know
is, if you are going to actually write a program or a project of some sort,
how do you actually start.

Picture this, you know what you want the program to do (its features), you
have a possably rough idea of how the program will work. You have opened an
empty text file and saved it as 'mykewlprogram. py' and now your sitting in
front of an empty text file... Now then.... where do I start.

Any ideas about this problem :-)


In addition to what others have said, I use the interactive
interpreter A LOT (probably too much; I should write more tests).

Cheers,
mwh

--
... the U.S. Department of Transportation today disclosed that its
agents have recently cleared airport security checkpoints with an
M1 tank, a beluga whale, and a fully active South American volcano.
-- http://www.satirewire.com/news/march02/screeners.shtml
Jul 18 '05 #12
>>>>> "nick" == Nick Evans <ni**@huff.org. uk> writes:

nick> have a possably rough idea of how the program will work. You
nick> have opened an empty text file and saved it as
nick> 'mykewlprogram. py' and now your sitting in front of an empty
nick> text file... Now then.... where do I start.

Typically, a program reads a bunch of data, crunches it and outputs
it. Find a trivial way to get the necessary data into elementary
Python data structures like lists, tuples and dicts (many typical
programs don't need classes at all). Write a function to process that
data, resulting in a bunch of new objects (data
structures). pprint.pprint the resulting objects, and after you are
satisfied with the output, perform the necessary actions according to
the objects. The rest is just chrome.

If you are interested in starting with the chrome (a'la VB), check out
PythonCard (or Boa constructor, or equivalent).

--
Ville Vainio http://tinyurl.com/2prnb
Jul 18 '05 #13
Ksenia Marasanova schreef:
Any ideas about this problem :-)


I dont' know if this is a 'right' approach, but if the program has user
interface, it helps also first to create this user interface. That way
you'll be able to visualize what information your program needs to get
and to send back. It can be easier then to define classes and
methods...


I disagree. In that case, better to define the data structures
you're program is going to manipulate.
--
Peter Kleiweg L:NL,af,da,de,e n,ia,nds,no,sv, (fr,it) S:NL,de,en,(da, ia)
info: http://www.let.rug.nl/~kleiweg/ls.html

Jul 18 '05 #14
Nick Evans wrote:
Hello there,
I have been on and off learning to code (with python being the second
language I have worked on after a bit of BASIC). What I really want to know
is, if you are going to actually write a program or a project of some sort,
how do you actually start.

Picture this, you know what you want the program to do (its features), you
have a possably rough idea of how the program will work. You have opened an
empty text file and saved it as 'mykewlprogram. py' and now your sitting in
front of an empty text file... Now then.... where do I start.

Any ideas about this problem :-)

Ta
Nick

Nick,
Open another file and write the story of your program;
why you're writing it, what it does, roughly how it does
it, what it operates on, who uses it, what it produces,
special problems, future considerations; a general
description.

Make another file listing specific things each user
will be able to do; his action and what is produced and
in what form.

By this time you should have an idea of what the
user interface will look like; gui, command line(both),
menu(s).

All things move forward together.

Possibly; code an interface only with all the menus.

Come up with data structures; empty classes with
only documentation and maybe variable names and empty
methods.

Put this at the bottom of every py file:
if __name__ == "__main__":
pass
Most of the time of you do anything to the file, put
a test in and test it here. As new tests are done,
describe them and comment out the last one.

Pick the most risky processe(s) and design/code.
Risky meaning is it doable and will your current
concept get the job done.

Test.

Iterate.

wes

Jul 18 '05 #15
Nick Evans wrote:
Hello there,
I have been on and off learning to code (with python being the second
language I have worked on after a bit of BASIC). What I really want to know
is, if you are going to actually write a program or a project of some sort,
how do you actually start.

<snip>
Hello,

It's good that you are thinking of this rather than just
trying to manically write some code to see what happens. As a general
point, there is a system that you can use to help you model out your
program (taught to most computer science students). This system is
called UML (Unified Modeling Language) - I would advise getting a good
book about UML and reading through that. It's is complementary to the
XP (Extreme Programming) stuff that people are talking about.

However, be aware that some of the concepts assumed in UML don't mix
too well to the 'Pythonic' way of doing things. If you want to have a
try writing some UML here are two systems you can get - there are others
- (I can't remember the links off the top of my head) they are an
OpenSource system called 'ArgoUML' or the community edition of
'Together' from Borland. Personally I prefer Together.

Cheers,

Neil

--

Neil Benn
Senior Automation Engineer
Cenix BioScience
BioInnovations Zentrum
Tatzberg 47
D-01307
Dresden
Germany

Tel : +49 (0)351 4173 154
e-mail : be**@cenix-bioscience.com
Cenix Website : http://www.cenix-bioscience.com

Jul 18 '05 #16
Hello,
now my 2 cents about this topic...
1. Get a good text editor.
When you already sit in front of an empty file, this point is
apparently done ;-)
2. Get a or "the" revision control system. It is freely available for
personal use.
3. Do not start with a program that only accepts input from the
console and sends output to the console, but learn how to handle files
so that you can store the information you fed into your program and
the data you get out.
4. Don´t try to make your code as short as possible, but as readable
as possible. Don´t put too many statements in a single line. Don´t use
too many list comprehensions and stuff like that in the beginning too
frequently.
5. Document your code lines from the very beginning. Don´t leave out
any commenting of your code because in the moment you code it is just
completely clear to you what the code means, is supposed to do and how
it works. It neccessarily won´t be that clear tomorrow.
6. Don´t make your variable names too short. Give them names that
describe what they are, and try to use similar name patterns for
similar variables. Use names that can be unambigously identified by a
search pattern, so that you will find occurences of variables quickly
without too much overhead.
7. Oops, I almost forgot: get a language that can be learned quickly
so that you get your code together without too much head scratching,
but a language that lets you also use advanced concepts when you are
ripe for them. Since you are posting in comp.lang.pytho n, this is
apparently already done as well.
Have fun

Peter
Jul 18 '05 #17
Max M wrote:
Jp Calderone wrote:
Close the file. Open test_mykewlprog ram.py and begin writing unit
tests.
I completely agree in the value of test driven development, but for
someone writing a first program I completely disagree!

He will have to fight both programming in itself, and the test driven
development process.


I would have thought that the TDD process was *how* one would "fight
programming". Do you have a better way? All the approaches I've
seen in the past were much, much more difficult and less assured
of useful results in a reasonable time.

(Also, as a new programmer, he is unlikely to have to "fight"
TDD, since he doesn't have other approaches to try to unlearn.
I assume unlearning old habits is what you were thinking about,
because TDD itself is so simple that it's not at all hard to
actually follow the process.)
There is a big difference in learning to program, and in programming
itself.

You should simply start coding! Solve problems as you go along. The most
important thing is to allways be aware when something is repeated.
It seems to me the OP was asking *how* to "start coding". Telling
him merely to do so is not likely to help. He already knows he
has to start coding...
Dont Repeat Yourself
=============== =====

If you have written a similar piece of code 3 times, you should refactor
it into a function.


How does he get any code at all, when he doesn't know how
to start? You can't refactor what doesn't exist.

-Peter
Jul 18 '05 #18
Neil Benn wrote:
Nick Evans wrote:
I have been on and off learning to code ...
It's good that you are thinking of this rather than just trying
to manically write some code to see what happens. As a general point,
there is a system that you can use to help you model out your program
(taught to most computer science students). This system is called UML
(Unified Modeling Language) - I would advise getting a good book about
UML and reading through that.


Ahhh!! Run! Run, Neil, run! UML!
It's is complementary to the XP (Extreme
Programming) stuff that people are talking about.


Ahhh!!! Run away some more! UML and XP are nearly anti-thetical.
Don't even consider going there. (Well, consider it, but please
don't waste any money buying a UML book as you do. Find a few
web sites, then ... run away! It's cheaper that way.)

In my opinion, if you try to get a beginning programmer to work using
UML when he isn't even sure how to start writing code in an empty
file, you will not have a beginning programmer for long. And I
don't mean because you've just got him over that initial hump...

In another opinion of mine, if you try to get a more advanced
programmer to work using UML, you also deserve whatever you get...

-rabidly-anti-UML-ically y'rs,
Peter
Jul 18 '05 #19
Hello,

On Tuesday 07 September 2004 01:02, Peter Hansen wrote:
Neil Benn wrote:
Nick Evans wrote:
I have been on and off learning to code ...


It's good that you are thinking of this rather than just trying
to manically write some code to see what happens. As a general point,
there is a system that you can use to help you model out your program
(taught to most computer science students). This system is called UML yes, I know ;-) (Unified Modeling Language) - I would advise getting a good book about
UML and reading through that.


Ahhh!! Run! Run, Neil, run! UML!


Please, stay calm ! I recommend you not to run because because UML is nothing
you should fear, but also forget about the UML book FOR THE MOMENT !

Please reflect on your goals. Why do you want to write programs, what are they
meant to be used for in the end ? If you want to write very small programs to
be used like shell scripts on your private Linux box, then never spend your
time with UML, extreme programming, unit tests and all that stuff.
If you plan to write rich featured applications or even deamon processes then
first lean the basic ideas of how to write code. There are lots of tutorials
and books around that help you gain success very quickly. Write some little
apps and watch them doing their job.
When you're done, then take care of how to write bigger programs. Now you
should learn how to design an application, in what parts or modules it should
be implemented and how these modules shall communicate / work together. This
is what you should utilize PARTS of UML for. I strongly recommend you to look
at static structure diagrams, use cases and time line diagrams. The other
parts of UML are only useful in theory, they take much more time to be
created than they will ever save.
Once you are familiar with basic Python programming and with application
design (e.g. UML), then the last step I recommend to become a *nearly* (who
really claims to be completely) perfect developer is to understand the
importance of testing. When you are implementing a real big application you
are lost without it. I am using unit tests and they help me very much. With
these you can test first very small parts of your application and then later
combine the test to cover more and more of the whole program. Indeed there is
no need to argue for unit testing (when writing really big applications): try
it and you will appreciate it !

Regards,
Alex
It's is complementary to the XP (Extreme
Programming) stuff that people are talking about.


Ahhh!!! Run away some more! UML and XP are nearly anti-thetical.
Don't even consider going there. (Well, consider it, but please
don't waste any money buying a UML book as you do. Find a few
web sites, then ... run away! It's cheaper that way.)

In my opinion, if you try to get a beginning programmer to work using
UML when he isn't even sure how to start writing code in an empty
file, you will not have a beginning programmer for long. And I
don't mean because you've just got him over that initial hump...

In another opinion of mine, if you try to get a more advanced
programmer to work using UML, you also deserve whatever you get...

-rabidly-anti-UML-ically y'rs,
Peter

Jul 18 '05 #20

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

Similar topics

3
5767
by: dataguy | last post by:
I can't find it anywhere in the manual, but I have a developer that wants to know if we can code a trigger to capture the data that has changed in a table only if certain columns have changed. It looks like I can do it with the when clause and check the old vs new, but that would get very ugly with a large table. Has anyone done something like this?
2
3070
by: Jeevan | last post by:
Hi, I have an array of data (which I am getting from a socket connection). I am working on a program which acts on this data but the program is written to work on data from a file (not from an array). I cannot change anything in the program but can add some features by which I can convert this array of data into a file. The easiest thing would be to write the data into a file (in hard disk) and use it. But I will be working on thousands...
18
3712
by: jacob navia | last post by:
In C, we have read-only memory (const), read/write memory (normal data), and write only memory. Let's look at the third one in more detail. Write only memory is a piece of RAM that can only be written to, since its contents are undefined. The program is allocating a new piece of data, and the previous contents aren't relevant. This memory
15
1404
by: John Salerno | last post by:
Ok, I've been reading an intro book to C# and I'm learning a lot of the basics. I can follow along with all the sample code and understand exactly what it's doing, but I know there's no way I'd be able to write the code myself. Also, it seems like every time I come here, or read info online, there is so much complicated stuff that I haven't even seen yet. Basically what I'm wanting to know is, how long do you expect it to take a...
13
2067
by: Jacek Dziedzic | last post by:
Hi! <OT, background> I am in a situation where I use two compilers from different vendors to compile my program. It seems that recently, due to a misconfiguration, library conflict or my ignorance, with one of the compilers I am having trouble related to libuwind.so, which, to my knowledge, deals with the intricacies of unwinding the stack upon an exception. Executables compiled with this compiler crash with a SEGV after throw(), never...
0
9589
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...
0
10212
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10047
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9995
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
8872
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
7410
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
6674
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
5304
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...
1
3962
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.