A quick introduction on code standards, documentation and testing for first year grading students. Very incomplete and opinionated. Still fun and interesting, I hope!
Learn how to write better code. Follow key software development principles like KISS, DRY, YAGNI, and SOLID. Know how to choose better names, structure your code, write methods, and design classes.
Undefined behavior is closer than you thinkAndrey Karpov
Some people think that undefined behavior is caused only by gross errors (accessing outside the bounds of the array, for instance) or inadequate constructions (i = i++ + ++i, for example). That's why it is quite surprising when a programmer sees undefined behavior in the code that used to work correctly, without arousing any suspicion. One should never let his guard down, programming in C/C++. Because hell is closer than you may think.
Keep Code Left - How to write better code in almost any languageMick Andrew
Mick claims that 50% of all "else" statements are not needed, and are harmful to your code's readability, reliability and maintainability.
Come hear and see some simple guidelines that can help coders in almost any language that has if-then-else and loop-continue statements write better code, and perform rule-driven code reviews at a glance with no software tools needed. Come learn what a "filter" is, and where they should be coded.
The article will help the readers understand what size_t and ptrdiff_t types are, what they are used for and when they must be used. The article will be interesting for those developers who begin creation of 64-bit applications where use of size_t and ptrdiff_t types provides high performance, possibility to operate large data sizes and portability between different platforms.
This is part 1 of fuzzing, an introduction to the subject. This presentation covers some of theory and thought process behind the subject, as well as an introduction to environment variable fuzzing and file format fuzzing.
Learn how to write better code. Follow key software development principles like KISS, DRY, YAGNI, and SOLID. Know how to choose better names, structure your code, write methods, and design classes.
Undefined behavior is closer than you thinkAndrey Karpov
Some people think that undefined behavior is caused only by gross errors (accessing outside the bounds of the array, for instance) or inadequate constructions (i = i++ + ++i, for example). That's why it is quite surprising when a programmer sees undefined behavior in the code that used to work correctly, without arousing any suspicion. One should never let his guard down, programming in C/C++. Because hell is closer than you may think.
Keep Code Left - How to write better code in almost any languageMick Andrew
Mick claims that 50% of all "else" statements are not needed, and are harmful to your code's readability, reliability and maintainability.
Come hear and see some simple guidelines that can help coders in almost any language that has if-then-else and loop-continue statements write better code, and perform rule-driven code reviews at a glance with no software tools needed. Come learn what a "filter" is, and where they should be coded.
The article will help the readers understand what size_t and ptrdiff_t types are, what they are used for and when they must be used. The article will be interesting for those developers who begin creation of 64-bit applications where use of size_t and ptrdiff_t types provides high performance, possibility to operate large data sizes and portability between different platforms.
This is part 1 of fuzzing, an introduction to the subject. This presentation covers some of theory and thought process behind the subject, as well as an introduction to environment variable fuzzing and file format fuzzing.
Modelação de Dados com DER e Modelo Relacional, das aulas de Planeamento de Sistemas de Informação do Mestrado em Informação Empresarial da Escola Superior de Estudos Industriais e de Gestão do Instituto Politécnico do Porto.
Aula 04 - Introdução aos Diagramas de SequênciaAlberto Simões
Introdução ultra-light aos diagramas de sequência, para a disciplina de planeamento de sistemas de informação do mestrado em informação empresarial da escola superior de estudos industriais e de gestão do instituto politecnico do porto, ano lectivo de 2012/2013.
Aula 03 - Introdução aos Diagramas de AtividadeAlberto Simões
Introdução aos Diagramas de Atividade (UML) para a disciplina de Planeamento de Sistemas de Informação do Mestrado em Informação Empresarial da Escola Superior de Estudos Industriais e de Gestão do Instituto Politécnico do Porto.
Uma introdução ligeira às redes de PERT e gráficos de GANTT. Aula de Planeamento de Sistemas de Informação do Mestrado em Informação Empresarial da Escola Superior de Estudos Industriais e de Gestão, do Instituto Politécnico do Cávado e do Ave.
Apresentação sobre arquitecturas de tradução automática, realizada na Escola de Verão em PLN realizada em 2009 na Faculdade de Letras da Universidade do Porto, Portugal.
Extracção de Recursos para Tradução AutomáticaAlberto Simões
Apresentação sobre extracção de recursos para tradução automática, realizada na Escola de Verão em PLN realizada em 2009 na Faculdade de Letras da Universidade do Porto, Portugal.
top nidhi software solution freedownloadvrstrong314
This presentation emphasizes the importance of data security and legal compliance for Nidhi companies in India. It highlights how online Nidhi software solutions, like Vector Nidhi Software, offer advanced features tailored to these needs. Key aspects include encryption, access controls, and audit trails to ensure data security. The software complies with regulatory guidelines from the MCA and RBI and adheres to Nidhi Rules, 2014. With customizable, user-friendly interfaces and real-time features, these Nidhi software solutions enhance efficiency, support growth, and provide exceptional member services. The presentation concludes with contact information for further inquiries.
Check out the webinar slides to learn more about how XfilesPro transforms Salesforce document management by leveraging its world-class applications. For more details, please connect with sales@xfilespro.com
If you want to watch the on-demand webinar, please click here: https://www.xfilespro.com/webinars/salesforce-document-management-2-0-smarter-faster-better/
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Globus
The Earth System Grid Federation (ESGF) is a global network of data servers that archives and distributes the planet’s largest collection of Earth system model output for thousands of climate and environmental scientists worldwide. Many of these petabyte-scale data archives are located in proximity to large high-performance computing (HPC) or cloud computing resources, but the primary workflow for data users consists of transferring data, and applying computations on a different system. As a part of the ESGF 2.0 US project (funded by the United States Department of Energy Office of Science), we developed pre-defined data workflows, which can be run on-demand, capable of applying many data reduction and data analysis to the large ESGF data archives, transferring only the resultant analysis (ex. visualizations, smaller data files). In this talk, we will showcase a few of these workflows, highlighting how Globus Flows can be used for petabyte-scale climate analysis.
How to Position Your Globus Data Portal for Success Ten Good PracticesGlobus
Science gateways allow science and engineering communities to access shared data, software, computing services, and instruments. Science gateways have gained a lot of traction in the last twenty years, as evidenced by projects such as the Science Gateways Community Institute (SGCI) and the Center of Excellence on Science Gateways (SGX3) in the US, The Australian Research Data Commons (ARDC) and its platforms in Australia, and the projects around Virtual Research Environments in Europe. A few mature frameworks have evolved with their different strengths and foci and have been taken up by a larger community such as the Globus Data Portal, Hubzero, Tapis, and Galaxy. However, even when gateways are built on successful frameworks, they continue to face the challenges of ongoing maintenance costs and how to meet the ever-expanding needs of the community they serve with enhanced features. It is not uncommon that gateways with compelling use cases are nonetheless unable to get past the prototype phase and become a full production service, or if they do, they don't survive more than a couple of years. While there is no guaranteed pathway to success, it seems likely that for any gateway there is a need for a strong community and/or solid funding streams to create and sustain its success. With over twenty years of examples to draw from, this presentation goes into detail for ten factors common to successful and enduring gateways that effectively serve as best practices for any new or developing gateway.
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisGlobus
JASMIN is the UK’s high-performance data analysis platform for environmental science, operated by STFC on behalf of the UK Natural Environment Research Council (NERC). In addition to its role in hosting the CEDA Archive (NERC’s long-term repository for climate, atmospheric science & Earth observation data in the UK), JASMIN provides a collaborative platform to a community of around 2,000 scientists in the UK and beyond, providing nearly 400 environmental science projects with working space, compute resources and tools to facilitate their work. High-performance data transfer into and out of JASMIN has always been a key feature, with many scientists bringing model outputs from supercomputers elsewhere in the UK, to analyse against observational or other model data in the CEDA Archive. A growing number of JASMIN users are now realising the benefits of using the Globus service to provide reliable and efficient data movement and other tasks in this and other contexts. Further use cases involve long-distance (intercontinental) transfers to and from JASMIN, and collecting results from a mobile atmospheric radar system, pushing data to JASMIN via a lightweight Globus deployment. We provide details of how Globus fits into our current infrastructure, our experience of the recent migration to GCSv5.4, and of our interest in developing use of the wider ecosystem of Globus services for the benefit of our user community.
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns
Unlocking Business Potential: Tailored Technology Solutions by Prosigns
Discover how Prosigns, a leading technology solutions provider, partners with businesses to drive innovation and success. Our presentation showcases our comprehensive range of services, including custom software development, web and mobile app development, AI & ML solutions, blockchain integration, DevOps services, and Microsoft Dynamics 365 support.
Custom Software Development: Prosigns specializes in creating bespoke software solutions that cater to your unique business needs. Our team of experts works closely with you to understand your requirements and deliver tailor-made software that enhances efficiency and drives growth.
Web and Mobile App Development: From responsive websites to intuitive mobile applications, Prosigns develops cutting-edge solutions that engage users and deliver seamless experiences across devices.
AI & ML Solutions: Harnessing the power of Artificial Intelligence and Machine Learning, Prosigns provides smart solutions that automate processes, provide valuable insights, and drive informed decision-making.
Blockchain Integration: Prosigns offers comprehensive blockchain solutions, including development, integration, and consulting services, enabling businesses to leverage blockchain technology for enhanced security, transparency, and efficiency.
DevOps Services: Prosigns' DevOps services streamline development and operations processes, ensuring faster and more reliable software delivery through automation and continuous integration.
Microsoft Dynamics 365 Support: Prosigns provides comprehensive support and maintenance services for Microsoft Dynamics 365, ensuring your system is always up-to-date, secure, and running smoothly.
Learn how our collaborative approach and dedication to excellence help businesses achieve their goals and stay ahead in today's digital landscape. From concept to deployment, Prosigns is your trusted partner for transforming ideas into reality and unlocking the full potential of your business.
Join us on a journey of innovation and growth. Let's partner for success with Prosigns.
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Shahin Sheidaei
Games are powerful teaching tools, fostering hands-on engagement and fun. But they require careful consideration to succeed. Join me to explore factors in running and selecting games, ensuring they serve as effective teaching tools. Learn to maintain focus on learning objectives while playing, and how to measure the ROI of gaming in education. Discover strategies for pitching gaming to leadership. This session offers insights, tips, and examples for coaches, team leads, and enterprise leaders seeking to teach from simple to complex concepts.
Into the Box Keynote Day 2: Unveiling amazing updates and announcements for modern CFML developers! Get ready for exciting releases and updates on Ortus tools and products. Stay tuned for cutting-edge innovations designed to boost your productivity.
Large Language Models and the End of ProgrammingMatt Welsh
Talk by Matt Welsh at Craft Conference 2024 on the impact that Large Language Models will have on the future of software development. In this talk, I discuss the ways in which LLMs will impact the software industry, from replacing human software developers with AI, to replacing conventional software with models that perform reasoning, computation, and problem-solving.
Globus Connect Server Deep Dive - GlobusWorld 2024Globus
We explore the Globus Connect Server (GCS) architecture and experiment with advanced configuration options and use cases. This content is targeted at system administrators who are familiar with GCS and currently operate—or are planning to operate—broader deployments at their institution.
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...informapgpstrackings
Keep tabs on your field staff effortlessly with Informap Technology Centre LLC. Real-time tracking, task assignment, and smart features for efficient management. Request a live demo today!
For more details, visit us : https://informapuae.com/field-staff-tracking/
A Comprehensive Look at Generative AI in Retail App Testing.pdfkalichargn70th171
Traditional software testing methods are being challenged in retail, where customer expectations and technological advancements continually shape the landscape. Enter generative AI—a transformative subset of artificial intelligence technologies poised to revolutionize software testing.
Software Engineering, Software Consulting, Tech Lead.
Spring Boot, Spring Cloud, Spring Core, Spring JDBC, Spring Security,
Spring Transaction, Spring MVC,
Log4j, REST/SOAP WEB-SERVICES.
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Globus
The U.S. Geological Survey (USGS) has made substantial investments in meeting evolving scientific, technical, and policy driven demands on storing, managing, and delivering data. As these demands continue to grow in complexity and scale, the USGS must continue to explore innovative solutions to improve its management, curation, sharing, delivering, and preservation approaches for large-scale research data. Supporting these needs, the USGS has partnered with the University of Chicago-Globus to research and develop advanced repository components and workflows leveraging its current investment in Globus. The primary outcome of this partnership includes the development of a prototype enterprise repository, driven by USGS Data Release requirements, through exploration and implementation of the entire suite of the Globus platform offerings, including Globus Flow, Globus Auth, Globus Transfer, and Globus Search. This presentation will provide insights into this research partnership, introduce the unique requirements and challenges being addressed and provide relevant project progress.
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar
The European Union Agency for Law Enforcement Cooperation (Europol) has suffered an alleged data breach after a notorious threat actor claimed to have exfiltrated data from its systems. Infamous data leaker IntelBroker posted on the even more infamous BreachForums hacking forum, saying that Europol suffered a data breach this month.
The alleged breach affected Europol agencies CCSE, EC3, Europol Platform for Experts, Law Enforcement Forum, and SIRIUS. Infiltration of these entities can disrupt ongoing investigations and compromise sensitive intelligence shared among international law enforcement agencies.
However, this is neither the first nor the last activity of IntekBroker. We have compiled for you what happened in the last few days. To track such hacker activities on dark web sources like hacker forums, private Telegram channels, and other hidden platforms where cyber threats often originate, you can check SOCRadar’s Dark Web News.
Stay Informed on Threat Actors’ Activity on the Dark Web with SOCRadar!
Developing Distributed High-performance Computing Capabilities of an Open Sci...Globus
COVID-19 had an unprecedented impact on scientific collaboration. The pandemic and its broad response from the scientific community has forged new relationships among public health practitioners, mathematical modelers, and scientific computing specialists, while revealing critical gaps in exploiting advanced computing systems to support urgent decision making. Informed by our team’s work in applying high-performance computing in support of public health decision makers during the COVID-19 pandemic, we present how Globus technologies are enabling the development of an open science platform for robust epidemic analysis, with the goal of collaborative, secure, distributed, on-demand, and fast time-to-solution analyses to support public health.
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Anthony Dahanne
Les Buildpacks existent depuis plus de 10 ans ! D’abord, ils étaient utilisés pour détecter et construire une application avant de la déployer sur certains PaaS. Ensuite, nous avons pu créer des images Docker (OCI) avec leur dernière génération, les Cloud Native Buildpacks (CNCF en incubation). Sont-ils une bonne alternative au Dockerfile ? Que sont les buildpacks Paketo ? Quelles communautés les soutiennent et comment ?
Venez le découvrir lors de cette session ignite
Enhancing Research Orchestration Capabilities at ORNL.pdfGlobus
Cross-facility research orchestration comes with ever-changing constraints regarding the availability and suitability of various compute and data resources. In short, a flexible data and processing fabric is needed to enable the dynamic redirection of data and compute tasks throughout the lifecycle of an experiment. In this talk, we illustrate how we easily leveraged Globus services to instrument the ACE research testbed at the Oak Ridge Leadership Computing Facility with flexible data and task orchestration capabilities.
8. code problems
∙ Legibility Issues;
∙ Code should document itself;
∙ Code should be easy to read;
∙ Code should be elegant!
4
9. code problems
∙ Legibility Issues;
∙ Code should document itself;
∙ Code should be easy to read;
∙ Code should be elegant!
∙ Documentation Issues;
4
10. code problems
∙ Legibility Issues;
∙ Code should document itself;
∙ Code should be easy to read;
∙ Code should be elegant!
∙ Documentation Issues;
∙ Documentation should exist;
4
11. code problems
∙ Legibility Issues;
∙ Code should document itself;
∙ Code should be easy to read;
∙ Code should be elegant!
∙ Documentation Issues;
∙ Documentation should exist;
∙ Documentation should follow standards;
4
12. code problems
∙ Legibility Issues;
∙ Code should document itself;
∙ Code should be easy to read;
∙ Code should be elegant!
∙ Documentation Issues;
∙ Documentation should exist;
∙ Documentation should follow standards;
∙ Documentation should document!
4
13. code problems
∙ Legibility Issues;
∙ Code should document itself;
∙ Code should be easy to read;
∙ Code should be elegant!
∙ Documentation Issues;
∙ Documentation should exist;
∙ Documentation should follow standards;
∙ Documentation should document!
∙ Testing Issues;
4
14. code problems
∙ Legibility Issues;
∙ Code should document itself;
∙ Code should be easy to read;
∙ Code should be elegant!
∙ Documentation Issues;
∙ Documentation should exist;
∙ Documentation should follow standards;
∙ Documentation should document!
∙ Testing Issues;
∙ Code should work on correct input;
4
15. code problems
∙ Legibility Issues;
∙ Code should document itself;
∙ Code should be easy to read;
∙ Code should be elegant!
∙ Documentation Issues;
∙ Documentation should exist;
∙ Documentation should follow standards;
∙ Documentation should document!
∙ Testing Issues;
∙ Code should work on correct input;
∙ Code should work on incorrect input;
4
16. code problems
∙ Legibility Issues;
∙ Code should document itself;
∙ Code should be easy to read;
∙ Code should be elegant!
∙ Documentation Issues;
∙ Documentation should exist;
∙ Documentation should follow standards;
∙ Documentation should document!
∙ Testing Issues;
∙ Code should work on correct input;
∙ Code should work on incorrect input;
∙ Code should be tested on every change!
4
19. use meaningful identifiers
What does this code do?
int x(string g[]) {
string p = g[0]; int o = p.length();
for (z=1;z<g.length;++z) {
if (g[z].length()>o) { p=g[z];o=p.length(); }
}
return o;
}
7
20. use meaningful identifiers
Is this better?
int x(string list[]) {
string maxString = list[0];
int maxSize = maxString.length();
for (i=1;i<list.length;++i) {
if (list[i].length()>maxSize) { maxString=list[i];
maxSize=maxString.length(); }
}
return maxSize;
}
8
21. use coherent indentation
Do you prefer this…
int x(string list[]) {
string maxString = list[0];
int maxSize = maxString.length();
for (i=1;i<list.length;++i) {
if (list[i].length()>maxSize) { maxString=list[i];
maxSize=maxString.length(); }
}
return maxSize;
}
9
22. use coherent indentation
or this?
int x(string list[]) {
string maxString = list[0];
int maxSize = maxString.length();
for (i=1;i<list.length;++i) {
if (list[i].length()>maxSize) {
maxString=list[i];
maxSize=maxString.length();
}
}
return maxSize;
}
10
23. use coherent identifiers
int x(string Lists[]) {
string max_String = Lista[0];
int maxSize = max_String.length();
for (i=1;i<Lista.length;++i) {
if (Lista[i].length()>maxSize) {
max_String=Lista[i];
maxSize=max_String.length();
}
}
return maxSize;
}
11
25. use coherent identifiers
Choose:
∙ One language:
I prefer English given keywords are English, but any will work!
∙ Use one variable style:
If you prefer use CamelCaseIdentifiers;
Or, why not, underscores_identifiers;
but not both!
12
26. use coherent identifiers
Choose:
∙ One language:
I prefer English given keywords are English, but any will work!
∙ Use one variable style:
If you prefer use CamelCaseIdentifiers;
Or, why not, underscores_identifiers;
but not both!
∙ Note that some languages have conventions:
Java libraries use CamelCase;
GNU Toolkit (GTK+) use underscores;
So, probably a good idea to follow the flow…
12
27. use standard code structure
Does this work?
int x(string list[]) {
; string maxString = list[0]
; int maxSize = maxString.length()
; for (i=1;i<list.length;++i)
if (list[i].length()>maxSize) {
; maxString=list[i]
; maxSize=maxString.length()
; }
; return maxSize
; }
Isn’t it cute?
13
28. use standard and coherent code structure
Choose one, but stick to it!
int x(string list[]) {
string maxString = list[0];
int maxSize = maxString.length();
for (i=1;i<list.length;++i)
if (list[i].length()>maxSize) {
maxString=list[i];
maxSize=maxString.length();
}
return maxSize;
}
int x(string list[])
{
string maxString = list[0];
int maxSize = maxString.length();
for (i=1;i<list.length;++i)
if (list[i].length()>maxSize)
{
maxString=list[i];
maxSize=maxString.length();
}
return maxSize;
}
14
29. use vertical alignment
Most editors suck and mess with vertical alignment.
Nevertheless, it is useful.
See the error?
Sprite tank=LoadSprite(”path/to/sprites/tank.png”);
Sprite chopper=LoadSprite(”path/to/sprtes/chopper.png”);
Sprite balloons=LoadSprite(”path/to/sprites/balloons.png”);
15
30. use vertical alignment
Most editors suck and mess with vertical alignment.
Nevertheless, it is useful.
See the error?
Sprite tank=LoadSprite(”path/to/sprites/tank.png”);
Sprite chopper=LoadSprite(”path/to/sprtes/chopper.png”);
Sprite balloons=LoadSprite(”path/to/sprites/balloons.png”);
And now?
Sprite tank = LoadSprite(”path/to/sprites/tank.png”);
Sprite chopper = LoadSprite(”path/to/sprtes/chopper.png”);
Sprite balloons = LoadSprite(”path/to/sprites/balloons.png”);
15
31. be explicit
C, Java and C# are tolerant, so you can write
if (foo < bar)
do_something(foo, bar);
Look, m’a! No curly brackets!
16
32. be explicit
C, Java and C# are tolerant, so you can write
if (foo < bar)
do_something(foo, bar);
Look, m’a! No curly brackets!
Problem? Later you might need to add an action and probably you
will add it like this:
if (foo < bar)
do_something(foo, bar);
do_something_else(foo, bar);
And does that do what you mean?
16
33. be explicit ii
So, how do you read this?
if (a < b)
if (b < c)
a = c;
else
c = b;
Or, more important, how does the compiler read it?
17
34. be explicit ii
So, how do you read this?
if (a < b)
if (b < c)
a = c;
else
c = b;
Or, more important, how does the compiler read it?
if (a < b)
if (b < c)
a = c;
else
c = b;
if (a < b)
if (b < c)
a = c;
else
c = b;
17
35. be explicit ii
Better with curly brackets!
if (a < b) {
if (b < c) {
a = c;
}
}
else {
c = b;
}
if (a < b) {
if (b < c) {
a = c;
}
else {
c = b;
}
}
Even without indentation you can understand it properly!!
And better! You do not need to know how the compiler interprets it.
18
36. use proper data structures
Implement related data as a data structure.
So, in pacman we have four ghosts. Store their positions.
int g1x, g1y, g2x, g2y, g3x, g3y, g4x, g4y;
19
37. use proper data structures
Implement related data as a data structure.
So, in pacman we have four ghosts. Store their positions.
int g1x, g1y, g2x, g2y, g3x, g3y, g4x, g4y;
There are only four, right? And it works!
19
38. use proper data structures
Implement related data as a data structure.
So, in pacman we have four ghosts. Store their positions.
int g1x, g1y, g2x, g2y, g3x, g3y, g4x, g4y;
There are only four, right? And it works!
Probably better:
class Pair { public int x, y; };
Pair[] ghost = new Pair[4];
// now use ghost[0].x, ghost[1].y, etc
19
41. should it exist?
Real programmers don’t comment their code,
if it was hard to write,
it should be hard to understand and harder to modify.
— unknown
22
42. should it exist?
Real programmers don’t comment their code,
if it was hard to write,
it should be hard to understand and harder to modify.
— unknown
Kidding. It should really exist!
22
43. is this documentation?
/* Computes the length of the longer string */
int LongestString(string list[])
{
string maxString = list[0];
int maxSize = maxString.length();
for (i=1; i<list.length; i++) {
if (list[i].length() > maxSize) {
maxString = list[i];
maxSize = maxString.length();
}
}
return maxSize;
}
23
44. is this documentation?
/* Computes the length of the longer string */
int LongestString(string list[])
{
string maxString = list[0];
int maxSize = maxString.length();
for (i=1; i<list.length; i++) {
if (list[i].length() > maxSize) {
maxString = list[i];
maxSize = maxString.length();
}
}
return maxSize;
}
Not really!
23
46. documentation content
Try to include:
∙ What the code is about;
∙ What are each of the input arguments/parameters;
∙ What is the type and content of the returned value;
∙ If any of the method/function parameters are for output;
∙ What restrictions does the input values have?
∙ What happens when you do not follow that restriction?
∙ What exceptions are thrown directy?
∙ What exceptions are not catched and might be propagated?
∙ What is the algorithm?
25
47. use standards
Most programming languages have a standard documentation
approach:
∙ Perl has POD;
∙ Java has JavaDoc;
∙ Haskell has Hadock;
∙ C# has “XML Comments”;
∙ Python has Sphinx;
∙ C has Doxygen;
∙ C++ has Doxygen too;
∙ Lots of cross-language tools;
26
48. example: javadoc
/**
* Given an array of strings, compute the length of the
* longest string.
* <p>
* This method will not work for empty lists.
*
* @param list the list of strings to be processed;
* @return the size of the longest string
* in the array;
*/
int LongestString(string list[])
{
string maxString = list[0];
int maxSize = maxString.length();
for (i=1; i<list.length; i++) {
[...]
27
51. does this work?
int LongestString(string list[])
{
string maxString = list[0];
int maxSize = maxString.length();
for (i=1; i<list.length; i++) {
if (list[i].length() > maxSize) {
maxString = list[i];
maxSize = maxString.length();
}
}
return maxSize;
}
30
52. does this work?
int LongestString(string list[])
{
string maxString = list[0];
int maxSize = maxString.length();
for (i=1; i<list.length; i++) {
if (list[i].length() > maxSize) {
maxString = list[i];
maxSize = maxString.length();
}
}
return maxSize;
}
Always!?
30
53. does this work?
int LongestString(string list[])
{
string maxString = list[0];
int maxSize = maxString.length();
for (i=1; i<list.length; i++) {
if (list[i].length() > maxSize) {
maxString = list[i];
maxSize = maxString.length();
}
}
return maxSize;
}
Always!?
What happens on the empty list?
30
54. unit testing
∙ Different tools have different approaches/tools;
∙ The idea is the same: test!
31
55. unit testing
∙ Different tools have different approaches/tools;
∙ The idea is the same: test!
∙ What to test?
31
56. unit testing
∙ Different tools have different approaches/tools;
∙ The idea is the same: test!
∙ What to test?
∙ Everything!
∙ Test a simple case;
∙ Test a large case;
∙ Test weird cases;
∙ Test limit cases!
31
57. do it yourself testing
static class Test {
static void is(int a, int b) {
System.out.println( a == b ? ”ok” : ”nok” );
}
}
32
58. do it yourself testing
static class Test {
static void is(int a, int b) {
System.out.println( a == b ? ”ok” : ”nok” );
}
}
Then…
string[] array = { ”banana”, ”apple”, ”strawberry” };
Test.is( 10, LongestString(array) );
string[] array1 = { ”pear” };
Test.is( 4, LongestString(array) );
32
59. do it yourself testing
You can ever try and test if a method throws an exception!
static class Test {
static void throws(Runnable code, Class<?> class) {
boolean ok = false;
try {
code.run();
} catch (Exception e) {
if (e instanceof class) ok = true;
}
System.out.println( ok ? ”ok” : ”nok” );
}
}
Non Tested Code!
33
60. testing: why?
∙ To know your code is working;
∙ To know your code is still working;
∙ To know that your latest change does not mess with your
working code;
34
61. must read
How To Write Unmaintainable Code
by Roedy Green
https://www.thc.org/root/phun/unmaintain.html
Thank you!
35