Efficient Code - A Level Computer Science (2024)

Intro

Writing Efficient Code

Efficiency in coding is very important. It allows you to speed up your development time and makes your code easier to read, debug and maintain. There are a number of different ways in which you can make your code more efficient, including:

  • Use of loops for repeated actions
  • Use of data structures instead of separate variables
  • Use of compound data structures
  • Use of functions & procedures
  • Use of in-built features / external code libraries
  • Use of recursion
  • Use of object orientated coding.
  • Separation of data from the code

Loops

Loops

Pretty much the first efficiency technique any beginner programmer learns is how to use a loop to improve efficiency.

  • You can use Unconditional loops(e.g. while loops) to repeatedly ask a question until a valid response is inputted.
  • You can use Iteration (for loops) to perform the same(or similar) action for a number of different items in a list.

Structures

Data Structures

Data structures allow the user to store multiple pieces of the same type of data using one single identifier name, rather than through multiple variables.

  • They work with loops making repetition more simple to perform.
  • The are quicker and easier to debug/maintain.

Compound Data Structures

Compound data structures, including 2 Dimensional arrays and dictionaries within dictionaries, allow for more efficient, maintainable and extendable code than separate arrays.

Functions

Functions & Procedures

Functions and procedures make your code more efficient because:

  • They allow repeated use throughout the file (and in order files)
  • They make your code more readable
  • Can be called within other functions making them even more powerful.
  • Functions allow the editing of the internal workings of a function without affect other logic outside of the function.

Libraries

External Libraries

Making use of external modules and optional downloadable modules allows for far more efficient coding, especially in larger projects.

  • You can implement functionality without reinventing the wheel.
  • You can use features that you don’t know how to implement
  • If an update of bug fix is rolled out, all users of the module can benefit from the improvements.

Of course there are risks associated with use external sources of a code, including:

You don’t know what the code is doing – it could be doing something malicious or malfunctioning in some way.
You can’t update the library yourself if there is an issue – you have to wait for a fix to be implemented.
Some libraries have a large storage /memory / CPU overhead in comparison to custom code implementations.

Recursion

Recursion

Some programming problems can only be solved , or be solved more efficiently through the use of recursion, where a function calls itself, for example:

  • Walking through directory trees
  • Implementing Stacks
  • Binary search
  • Divide and conquer sorting algorithms, such as merge sort.

For more information see the page on recursion.

OOP

Object Orientated Programming

In some situations, such as when you are trying to model real life objects or environments, then using object orientated programming techniques can massively improve the efficiency of your code. You code can become far more readable and adaptable.

Separation

Separation of data from code

When writing programs it is often beneficial to store data in a separate file, rather than in the program itself. This means that if the data needs to be changed then it can be done quickly and without risking damaging the code base. Using external data storage also makings implementing multilingual programs much easier, as when the program is loaded/installed a separate language file can be specified.

Efficient Code - A Level Computer Science (2024)
Top Articles
Dotfuscator Community - Visual Studio (Windows)
Where Are Mics & Cameras On Smart TVs? (We Found Them) | TechPenny
Farepay Login
How To Do A Springboard Attack In Wwe 2K22
Lighthouse Diner Taylorsville Menu
When is streaming illegal? What you need to know about pirated content
Tanger Outlets Sevierville Directory Map
Kostenlose Games: Die besten Free to play Spiele 2024 - Update mit einem legendären Shooter
Cranberry sauce, canned, sweetened, 1 slice (1/2" thick, approx 8 slices per can) - Health Encyclopedia
Hallelu-JaH - Psalm 119 - inleiding
Ssefth1203
Cool Math Games Bucketball
Programmieren (kinder)leicht gemacht – mit Scratch! - fobizz
Watch TV shows online - JustWatch
Craigslist Pets Sac
The Murdoch succession drama kicks off this week. Here's everything you need to know
Directions To O'reilly's Near Me
Craiglist Kpr
Roster Resource Orioles
Vistatech Quadcopter Drone With Camera Reviews
Nesz_R Tanjiro
3S Bivy Cover 2D Gen
Vintage Stock Edmond Ok
Hyvee Workday
Mc Donald's Bruck - Fast-Food-Restaurant
Quick Answer: When Is The Zellwood Corn Festival - BikeHike
Panola County Busted Newspaper
Www.craigslist.com Austin Tx
Belledelphine Telegram
Shelby Star Jail Log
Cinema | Düsseldorfer Filmkunstkinos
Babydepot Registry
Elijah Streams Videos
Pay Stub Portal
Ravens 24X7 Forum
Golden Tickets
Ma Scratch Tickets Codes
Aurora Il Back Pages
Craigslist Com Panama City Fl
Home Auctions - Real Estate Auctions
Isabella Duan Ahn Stanford
Bekah Birdsall Measurements
Wordle Feb 27 Mashable
Gas Buddy Il
Caphras Calculator
Sandra Sancc
Unblocked Games 6X Snow Rider
Terrell Buckley Net Worth
Anonib New
A Snowy Day In Oakland Showtimes Near Maya Pittsburg Cinemas
Electric Toothbrush Feature Crossword
Cataz.net Android Movies Apk
Latest Posts
Article information

Author: Amb. Frankie Simonis

Last Updated:

Views: 6532

Rating: 4.6 / 5 (76 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Amb. Frankie Simonis

Birthday: 1998-02-19

Address: 64841 Delmar Isle, North Wiley, OR 74073

Phone: +17844167847676

Job: Forward IT Agent

Hobby: LARPing, Kitesurfing, Sewing, Digital arts, Sand art, Gardening, Dance

Introduction: My name is Amb. Frankie Simonis, I am a hilarious, enchanting, energetic, cooperative, innocent, cute, joyous person who loves writing and wants to share my knowledge and understanding with you.