Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
f3d36fb
Remove old course content and add new pages
thomaskileyukaea Aug 9, 2023
cf49f19
Add a concluding section talking about YAGNI
thomaskileyukaea Aug 9, 2023
22ef936
Add headers for the various new pages
thomaskileyukaea Aug 9, 2023
046677d
Add in exercises for the new sections
thomaskileyukaea Aug 9, 2023
664afbc
Fix file name extensions
thomaskileyukaea Aug 9, 2023
d39c621
Add first draft of the software design episode
thomaskileyukaea Oct 10, 2023
e0e6da1
Add first draft of the pure functions section
thomaskileyukaea Oct 10, 2023
3103a3c
Adding first draft of the MVC section
thomaskileyukaea Oct 10, 2023
9c40c44
First draft of the class section of the episode
thomaskileyukaea Oct 17, 2023
860fbd8
First draft of the episode conclusion
thomaskileyukaea Oct 17, 2023
fcd6aa1
Update introduction to not mention paradigms
thomaskileyukaea Oct 18, 2023
0d06342
Move exercise about good and bad code before abstractions
thomaskileyukaea Oct 18, 2023
97f8590
Highlight where the code we are refactoring is
thomaskileyukaea Oct 18, 2023
78943f8
Expand the solution of the find problems with the code exercise
thomaskileyukaea Oct 18, 2023
77ffa14
Make the section explaining the tests clearer
thomaskileyukaea Oct 18, 2023
7f9b163
Add guidance to the regression test exericse
thomaskileyukaea Oct 18, 2023
253efda
Define regression testing before using it as exercise name
thomaskileyukaea Oct 18, 2023
81b414f
Add paragraph introducing cognitive load
thomaskileyukaea Oct 18, 2023
a2c5f2e
Fix type in introduction to pure functions
thomaskileyukaea Oct 18, 2023
6e69823
Add a bit about congitive load in advantages of pure functions
thomaskileyukaea Oct 18, 2023
0006a86
Explain that pure functions are easier to test ine one place
thomaskileyukaea Oct 18, 2023
b0f48e9
Incorporate the point about reuse pure functions into main text
thomaskileyukaea Oct 18, 2023
a653eeb
Highlight that the glue code is the non-pure code
thomaskileyukaea Oct 18, 2023
cd19c7f
USe model view presenter as alternative architecture
thomaskileyukaea Oct 18, 2023
5358305
Add header to call out about the controller
thomaskileyukaea Oct 18, 2023
b0d520d
Provide an example for how the model should be agnostic about the view
thomaskileyukaea Oct 18, 2023
4f727f0
Improve formatting of model/view classification exercise
thomaskileyukaea Oct 18, 2023
13b7df2
Emphasise the connection to the last episode
thomaskileyukaea Oct 18, 2023
a541c88
Improve clarity of first exercise in the MVC section
thomaskileyukaea Oct 18, 2023
e8375d4
Improve readability of the second exercise from the MVC section
thomaskileyukaea Oct 18, 2023
17f0395
Tightening up concluding paragraph
thomaskileyukaea Oct 18, 2023
9c8ec84
Fix semantic break in section about constructors
thomaskileyukaea Oct 18, 2023
19f07b3
Correct code sample to use write capitalisation for math.pi
thomaskileyukaea Oct 18, 2023
7f60230
Add examples for invariants and encapsulation
thomaskileyukaea Oct 18, 2023
66a904c
Add a callout about why maintaining invariants is good
thomaskileyukaea Oct 18, 2023
0f68b3e
Improve the class loading exercise content
thomaskileyukaea Oct 18, 2023
0c8817a
Add the controller modifications to the solution
thomaskileyukaea Oct 18, 2023
7924462
Fix spelling type in exercise title
thomaskileyukaea Oct 18, 2023
13bab51
Small fixes to flow of text in oop section
thomaskileyukaea Oct 18, 2023
3f3ecd3
Make the using classes in functional programming a callout
thomaskileyukaea Oct 18, 2023
bd41da7
Fixed incorrect usage of episode
thomaskileyukaea Oct 18, 2023
2bea011
Add diagram for solution to the architecture exercise
thomaskileyukaea Oct 18, 2023
10aa3fd
Remove redundant see this commit text
thomaskileyukaea Oct 18, 2023
3362067
Correct broken links in extras
thomaskileyukaea Oct 18, 2023
f766d70
Add initial timings for episodes
thomaskileyukaea Oct 23, 2023
4343b1d
Ensure model test is agnostic as to where it is run from
thomaskileyukaea Oct 23, 2023
515ed18
Correct example function name
thomaskileyukaea Oct 23, 2023
51cf100
Fixing spelling mistakes in refactoring functions exercise
thomaskileyukaea Oct 23, 2023
a79d394
Make sure there is an import for the Mock class
thomaskileyukaea Oct 23, 2023
c4e1146
Cover the changes needed to the regression test with the class refactor
thomaskileyukaea Oct 23, 2023
a77b9d6
Link decoupling to abstractions
thomaskileyukaea Oct 23, 2023
dfdb1a9
Make consistent use of first/second person
thomaskileyukaea Oct 23, 2023
aebc099
Ensure each problem links to a specific part of maintainable code
thomaskileyukaea Oct 23, 2023
a6e502a
Improve grammar of exercise solution
thomaskileyukaea Oct 23, 2023
35fd32d
Move MVC stuff after the classes section
thomaskileyukaea Oct 23, 2023
d1c3491
Combine YAGNI section into the MVC section
thomaskileyukaea Oct 23, 2023
05fee5b
Use consistent langauge - responsibilties - when talking about parts …
thomaskileyukaea Oct 23, 2023
dfcf219
Improve the flow of the start of the classes section
thomaskileyukaea Oct 23, 2023
1de7c86
Use correct name for CSVDataSource
thomaskileyukaea Oct 23, 2023
1f03d9e
Make the interfaces section not use real interfaces
thomaskileyukaea Oct 23, 2023
0df2ed8
Remove ... from example solution
thomaskileyukaea Oct 23, 2023
4488303
Ensure code samples consistent with new order
thomaskileyukaea Oct 23, 2023
54f3c9c
Fix formatting of solution regression test
thomaskileyukaea Oct 23, 2023
b663efa
Correct name of the regression test to match convention
thomaskileyukaea Oct 23, 2023
9eae6e2
Provide a skeleton for the test to make the exercise a bit easier
thomaskileyukaea Oct 23, 2023
c3d845c
Provide signature for pure function
thomaskileyukaea Oct 23, 2023
dc747dd
Use variable name data rather than all_loaded_data for example
thomaskileyukaea Oct 23, 2023
cafc20d
Introduce a header for the testing of pure functions section
thomaskileyukaea Oct 23, 2023
fa67fab
Add a hint showing how the class will be use
thomaskileyukaea Oct 23, 2023
c1eeb61
Remove bit about adding a layer of indirection
thomaskileyukaea Oct 23, 2023
51a1f99
Clarifying mocking section
thomaskileyukaea Oct 23, 2023
84edea9
Add skeleton test for writing the mock test
thomaskileyukaea Oct 23, 2023
3185e1b
Remind students to import the appropriate package
thomaskileyukaea Oct 23, 2023
f461a05
Make example actually build a JSON reader
thomaskileyukaea Oct 23, 2023
8ad11f7
Fix solutions based on testing
thomaskileyukaea Oct 23, 2023
47b3c81
Include the notion of writing tests before refactoring
thomaskileyukaea Oct 23, 2023
a672614
Reiterate running the regression test after each refactor
thomaskileyukaea Oct 23, 2023
e53f787
Correct capitalisation of files
thomaskileyukaea Nov 3, 2023
e7a3e0e
Fix missing fullstop
thomaskileyukaea Nov 3, 2023
224ea65
Fix line numbers for solutions based on change to code
thomaskileyukaea Nov 10, 2023
32ba1a1
Merged Thomas's work on section 3
anenadic Dec 12, 2023
8f1937b
Link and typo fixes
anenadic Dec 12, 2023
e3a994e
Initial pass over intro and first 2 episodes of section 3
anenadic Dec 14, 2023
b628416
Initial fix of config
anenadic Dec 14, 2023
e1f4e55
Mainly review of episode on refactoring
anenadic Dec 14, 2023
83ff771
Reworded the refactoring process a bit
anenadic Dec 15, 2023
8af5e71
More review of Thomas' work
anenadic Feb 27, 2024
5e135e0
More review of section 3
anenadic Feb 28, 2024
466b840
Added extra episdoe on OOP
anenadic Feb 28, 2024
e56693c
Review of episode on architecture
anenadic Feb 29, 2024
1efc791
Further updates the episode on architecture
anenadic Mar 1, 2024
0a36e7c
Fix for extras episode name
anenadic Mar 6, 2024
77169e2
#321 - Initial rework inc. section ordering and design goals
steve-crouch Mar 25, 2024
c44c2f5
Initial swap of refactoring and decoupling/abstractions episodes
anenadic Mar 25, 2024
d08fe3d
Added procedural programming episode
anenadic Mar 25, 2024
cba2d0c
Review of abstraction episode
anenadic Mar 25, 2024
5f27aaf
Review of refactoring episode
anenadic Mar 25, 2024
ef4af2e
Connected episodes better
anenadic Mar 26, 2024
4bc5198
#321 - revise software design learning narrative
steve-crouch Mar 27, 2024
960d9d2
Merge pull request #331 from carpentries-incubator/gh-pages
anenadic Mar 27, 2024
f2b7402
#321 - move software architecture episode to software design, update …
steve-crouch Mar 27, 2024
a27bcb3
Update _episodes/32-software-design.md
steve-crouch Mar 27, 2024
f4d0bc2
Update _episodes/32-software-design.md
steve-crouch Mar 27, 2024
939e275
Merge pull request #332 from carpentries-incubator/issue-321
steve-crouch Mar 27, 2024
2f4a115
Update _episodes/34-code-refactoring.md
anenadic Mar 27, 2024
b1345a6
Update _episodes/33-code-decoupling-abstractions.md
anenadic Mar 27, 2024
2c3b5ac
Update _episodes/33-code-decoupling-abstractions.md
anenadic Mar 27, 2024
db5837b
Fixes as per Steve's review on PR #327.
anenadic Mar 27, 2024
219a2ae
Merging changes to abstractions and refactoring episodes.
anenadic Mar 27, 2024
b5d2690
MErge of Section 3 changes
anenadic Mar 27, 2024
59806d4
Small working improvements
anenadic Mar 28, 2024
d621340
REmoved exercise times
anenadic Apr 10, 2024
5f3f8cd
Reworked section diagrams in Mermaid tool/svg
anenadic Apr 10, 2024
2df2d2b
Added an example of per-project dependency management tool. Fixes #162.
anenadic Apr 11, 2024
1b6f94f
Improved setup instructions. Fixes #111.
anenadic Apr 11, 2024
449547b
Update README.md
anenadic Apr 11, 2024
9a98364
Update README.md
anenadic Apr 11, 2024
994a155
Improved fix for winpty issue
anenadic Apr 11, 2024
b458af4
Wording update
anenadic Apr 12, 2024
75aa704
Merge pull request #338 from carpentries-incubator/anenadic-readme
anenadic Apr 12, 2024
bcaac51
🔀 Merge pull request #339 from carpentries-incubator/anenadic-winpty
bielsnohr Apr 16, 2024
a5b5277
Update setup.md
anenadic Apr 17, 2024
5b3a321
Update _episodes/12-virtual-environments.md
anenadic Apr 17, 2024
5336670
🔀 Merge pull request #337 from carpentries-incubator/issue-111
bielsnohr Apr 17, 2024
119e67e
Update _episodes/12-virtual-environments.md
anenadic Apr 17, 2024
09bc6db
🔀 Merge pull request #336 from carpentries-incubator/issue-162
bielsnohr Apr 17, 2024
7d455b0
Updated screenshot
anenadic Apr 19, 2024
54ca494
Revisions based on review
steve-crouch Apr 25, 2024
cb967db
Update _episodes/32-software-architecture-design.md
steve-crouch Apr 30, 2024
6934815
Merge pull request #340 from carpentries-incubator/screenshots
anenadic May 7, 2024
9917c8d
Merge pull request #342 from carpentries-incubator/stevecrouch-sectio…
anenadic May 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
[![DOI](https://zenodo.org/badge/257930838.svg)](https://zenodo.org/badge/latestdoi/257930838)

**Note that the lesson material can change at any point - if you are planning a workshop using this material,
either let the maintainers know or make sure you use your own fork of the lesson.**
## Intermediate Research Software Development Skills In Python Lesson

# Intermediate Research Software Development Skills In Python

An intermediate-level course in research software engineering and development skills and working as part of a
team (using Python as an example language). This lesson teaches intermediate-level software development
skills in a way that mimics a typical software development
process in a team, starting from an [existing piece of software](https://github.com/carpentries-incubator/python-intermediate-inflammation).
This is an intermediate-level course in collaborative research software engineering and development skills,
using Python as an example language.
It teaches these skills in a way that mimics a typical software development
process working as a part of a team,
starting from an [existing piece of software](https://github.com/carpentries-incubator/python-intermediate-inflammation).
The lesson is developed using [The Carpentries](https://carpentries.org) Jekyll lesson template.

A typical learner for this course may be someone who has gained basic software development skills either by
self-learning or attending a foundational course such as the novice [Software Carpentry Python course][swc-lessons].
Expand All @@ -17,25 +16,33 @@ development-related projects are now becoming larger and more complex and they n
intermediate software engineering skills to help them design more robust software code,
automate the process of testing and verifying its correctness and support collaborations with others.

> :warning: The course material can change at any point - if you are planning a workshop using this material,
either let the maintainers know or make sure you use your own fork of the lesson.

The lesson uses [patient inflammation data](https://swcarpentry.github.io/python-novice-inflammation/#scenario-a-miracle-arthritis-inflammation-cure) for code examples,
from the [Software Carpentry Python "inflammation" lesson](https://swcarpentry.github.io/python-novice-inflammation/).

Check out the [variant of this lesson](https://github.com/carpentries-incubator/python-intermediate-development-earth-sciences/tree/gh-pages)
that uses river catchment data in code examples (more suited for Earth and environmental scientists).

### Lesson Status

The lesson is currently in beta - it has been run over 10 times times with
The course is in a stable beta - it has been run over 15 times times with
different cohorts by the lesson authors as well as independently by people not directly involved in the lesson development
and is in a good state to be reused and taught by others.

## Teaching the Lesson

The lesson is suitable for both instructor-led teaching or guided self-learning where instructors provide help
The lesson is suitable for both instructor-led teaching or guided self-learning where helpers provide help
and answer questions (synchronously or asynchrounously) as learners go through the course on their own.
Initially, in sections 1-3 of the lesson,
learners are working on a software project and going though exercises individually.
In sections 4 and 5, they are grouped and work in teams,
as they would when collaborating on a team software project development.

The lesson has 5 sections;
each section can be delivered or worked through in self-learning mode over a half a day to a day,
each section can be delivered in one day by an instructor or worked through in self-learning mode over a half a day to a day,
depending on the pace.
We would recommend setting aside one day per section to make sure the delivery is not rushed.

If you would like to teach this lesson to your audience and help with more beta testing,
please let the lesson developers know by opening an [issue](https://github.com/carpentries-incubator/python-intermediate-development/issues/new?assignees=&labels=pilot&template=lesson-pilot-issue-template.md&title=) with your workshop details and a
Expand Down
5 changes: 5 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ extras_order:
- common-issues
- discuss
- vscode
- software-architecture-extra
- programming-paradigms
- procedural-programming
- functional-programming
- object-oriented-programming
- persistence
- databases
- quiz
Expand Down
20 changes: 20 additions & 0 deletions _episodes/00-setting-the-scene.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,27 @@ are transferable to other similar tools and programming languages.

The course is organised into the following sections:

{% comment %}
![Course overview diagram](../fig/course-overview.png){: .image-with-shadow width="800px" }
{% endcomment %}

![Course overview diagram](../fig/course-overview.svg){: .image-with-shadow width="1000px" }
{% comment %}
flowchart LR
A(1. Setting up
software environment)
--> B(2. Verifying
software correctness)
--> C(3. Software development
as a process)
--> D(4. Collaborative
development for reuse)
--> E(5. Managing software
over its lifetime)

https://mermaid.live/edit#pako:eNpdkE1rwzAMhv-K8CmFNrCvSw6D9eO2XlbYYeSiJXJqcKwgKyml9L_PaZox5pOQn8ey3oupuCZTGOv5VB1RFN4_ygDpvGUPORxI1YUG-m5qRrZ6QiGgMDjh0FLQBZRhtXqFdfaYwyeJs-ek_OMrFqFKA8U485vsKQ2YgZoG8tyND8LkYgSETrganUnZZs85bNh7_GZBdQPd2b-2ZQGhPtJd2mUvOewxYDNu8vujSeSBBJxG8M6SupYWZmlakhZdnWK5jFRp9EgtlaZIZU0We6-lKcM1odgrH86hMoVKT0vTdzUqbR02gq0pLPqYulQ7ZdlPUd8Sn8nd7Wa2OwxfzLN3_QE4H4oo

{% endcomment %}

### [Section 1: Setting up Software Environment](../10-section1-intro/index.html)
In the first section we are going to set up our working environment
Expand Down
25 changes: 25 additions & 0 deletions _episodes/10-section1-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,32 @@ As you get more comfortable with different tools and their alternatives,
you will select the one that is right for you based on your personal preferences
or based on what your collaborators are using.

{% comment %}
![Tools needed to collaborate on code development effectively](../fig/section1-overview.png){: .image-with-shadow width="800px" }
{% endcomment %}

![Tools needed to collaborate on code development effectively](../fig/section1-overview.svg){: .image-with-shadow width="1000px" }

{% comment %}
flowchart LR
A(1. Setting up
software environment

- Isolate and run code: command line, virtual environment & IDE
- Version control and share code: Git & GitHub
- Write well-written code: PEP8)
--> B(2. Verifying
software correctness)
--> C(3. Software development
as a process)
--> D(4. Collaborative
development for reuse)
--> E(5. Managing software
over its lifetime)

https://mermaid.live/edit#pako:eNpdkttKAzEQhl9lyIVsoS14AtkLQW3RggVRUJC9GXdn20A2s0wmLSK-u0m3K2IuQpj83z-H5MvU3JApTet4X29RFB6fKw9p3RSnc3ghVes3EHsYooFb3aMQkN9ZYd-R18oPdzNYBXaoBOgbkOghm5dp77occdbTFBKmEd1fgwAnsFosw2jzShIsZ9yrsDvYhW3OOhjeW01E2h_ix8i8iU2J9-TcbJ-OSmP2p-XT1aTys9k13BZn82xu28_U1L-GahahWj2FMIFBf1ecpxGMgoZ25LjPBR-HgQEQeuE6MwOyKC7mcMfO4QcLqt3RUfuXbllAKAY6Qsvicg5r9LjJs_6taAB5RwI2zcjZltR2NDFT05F0aJv0cF9ZVRndUkeVKdOxoRaj08pU_jtJMSq_fPralCqRpib2TXqihcWNYGfKFl1IUWqssqyHz3D4E6NyebgZ6R79O_PIff8AoRHADA

{% endcomment %}

Here is an overview of the tools we will be using.

Expand Down
148 changes: 28 additions & 120 deletions _episodes/11-software-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ and then obtain a local copy of that project (from your GitHub) on your machine.
> from your GitHub account into the home directory on your computer using SSH.
> Which command(s) would you use to get a detailed list of contents of the directory you have just cloned?
>
> Time: 5 min
>
> > ## Solution
> > 1. Find the SSH URL of the software project repository to clone from your GitHub account.
> > Make sure you do not clone the original repository but rather your own fork,
Expand Down Expand Up @@ -138,7 +138,7 @@ and then obtain a local copy of that project (from your GitHub) on your machine.
> {: .solution}
{: .challenge}

### Our Software Project Structure
## Our Software Project's Structure
Let’s inspect the content of the software project from the command line.
From the root directory of the project,
you can use the command `ls -l` to get a more detailed list of the contents.
Expand Down Expand Up @@ -210,7 +210,7 @@ each of the inflammation data files contains separate trial data for 60 patients
> Which command(s) would you use to list the contents or a first few
> lines of `data/inflammation-01.csv` file?
>
> Time: 1 min
>
> > ## Solution
> > 1. To list the entire content of a file from the project root do: `cat data/inflammation-01.csv`.
> > 2. To list the first 5 lines of a file from the project root do: `head -n 5 data/inflammation-01.csv`.
Expand All @@ -237,20 +237,22 @@ total 16
~~~
{: .language-bash}

An important thing to note here is that the structure of the project is not arbitrary.
An important thing to note here is that the structure of our project is not arbitrary.
One of the big differences between novice and intermediate software development is
planning the structure of your code.
This structure includes software components and behavioural interactions between them,
including how these components are laid out in a directory and file structure.
A novice will often make up the structure of their code as they go along.
However, for more advanced software development,
we need to plan this structure - called a *software architecture* - beforehand.
we need to plan and design this structure - called a *software architecture* - beforehand.

Let's have a more detailed look into what a software architecture is
Let's have a quick look into what a software architecture is
and which architecture is used by our software project
before we start adding more code to it.

## Software Architecture

### Software Architecture

A software architecture is the fundamental structure of a software system
that is decided at the beginning of project development
based on its requirements and cannot be changed that easily once implemented.
Expand Down Expand Up @@ -283,122 +285,28 @@ Another example of modules are classes in object-oriented programming languages.
>
{: .callout}

There are various software architectures around defining different ways of
dividing the code into smaller modules with well defined roles, for example:

- [Model–View–Controller (MVC) architecture](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller),
which we will look into in detail and use for our software project,
- [Service-oriented architecture (SOA)](https://en.wikipedia.org/wiki/Service-oriented_architecture),
which separates code into distinct services,
accessible over a network by consumers (users or other services)
that communicate with each other by passing data in a well-defined, shared format (protocol),
- [Client-server architecture](https://en.wikipedia.org/wiki/Client%E2%80%93server_model),
where clients request content or service from a server,
initiating communication sessions with servers,
which await incoming requests (e.g. email, network printing, the Internet),
- [Multilayer architecture](https://en.wikipedia.org/wiki/Multitier_architecture),
is a type of architecture in which presentation,
application processing
and data management functions
are split into distinct layers and may even be physically separated to run on separate machines -
some more detail on this later in the course.

### Model-View-Controller (MVC) Architecture
MVC architecture divides the related program logic
into three interconnected modules:

- **Model** (data)
- **View** (client interface), and
- **Controller** (processes that handle input/output and manipulate the data).

**Model** represents the data used by a program and also contains operations/rules
for manipulating and changing the data in the model.
This may be a database, a file, a single data object or a series of objects -
for example a table representing patients' data.

**View** is the means of displaying data to users/clients within an application
(i.e. provides visualisation of the state of the model).
For example, displaying a window with input fields and buttons (Graphical User Interface, GUI)
or textual options within a command line (Command Line Interface, CLI) are examples of Views.
They include anything that the user can see from the application.
While building GUIs is not the topic of this course,
we will cover building CLIs in Python in later episodes.

**Controller** manipulates both the **Model** and the **View**.
It accepts input from the **View**
and performs the corresponding action on the **Model** (changing the state of the model)
and then updates the **View** accordingly.
For example, on user request,
**Controller** updates a picture on a user's GitHub profile
and then modifies the **View** by displaying the updated profile back to the user.

#### MVC Examples

MVC architecture can be applied in scientific applications in the following manner.
Model comprises those parts of the application that deal with
some type of scientific processing or manipulation of the data,
e.g. numerical algorithm, simulation, DNA.
View is a visualisation, or format, of the output,
e.g. graphical plot, diagram, chart, data table, file.
Controller is the part that ties the scientific processing and output parts together,
mediating input and passing it to the model or view,
e.g. command line options, mouse clicks, input files.
For example, the diagram below depicts the use of MVC architecture for the
[DNA Guide Graphical User Interface application](https://www.software.ac.uk/developing-scientific-applications-using-model-view-controller-approach).

![MVC example of a DNA Guide Graphical User Interface application](../fig/mvc-DNA-guide-GUI.png){: .image-with-shadow width="400px" }
{% comment %}Image from https://www.software.ac.uk/developing-scientific-applications-using-model-view-controller-approach{% endcomment %}

> ## Exercise: MVC Application Examples From your Work
> Think of some other examples from your work or life
> where MVC architecture may be suitable
> or have a discussion with your fellow learners.
>
> Time: 5 min
> > ## Solution
> > MVC architecture is a popular choice when designing web and mobile applications.
> > Users interact with a web/mobile application by sending various requests to it.
> > Forms to collect users inputs/requests
> > together with the info returned and displayed to the user as a result represent the View.
> > Requests are processed by the Controller,
> > which interacts with the Model to retrieve or update the underlying data.
> > For example, a user may request to view its profile.
> > The Controller retrieves the account information for the user from the Model
> > and passes it to the View for rendering.
> > The user may further interact with the application
> > by asking it to update its personal information.
> > Controller verifies the correctness of the information
> > (e.g. the password satisfies certain criteria,
> > postal address and phone number are in the correct format, etc.)
> > and passes it to the Model for permanent storage.
> > The View is then updated accordingly and the user sees its updated profile details.
> >
> > Note that not everything fits into the MVC architecture
> > but it is still good to think about how things could be split into smaller units.
> > For a few more examples, have a look at this short
> > [article on MVC from CodeAcademy](https://www.codecademy.com/articles/mvc).
> {: .solution}
{: .challenge}
We are going to talk about software architecture and design a
bit more in [Section 3](../30-section3.html) - for now
it is sufficient to know that the way our software project's code is structured is intentional.

> ## Separation of Concerns
> Separation of concerns is important when designing software architectures
> in order to reduce the code's complexity.
> Note, however, there are limits to everything -
> and MVC architecture is no exception.
> Controller often transcends into Model and View
> and a clear separation is sometimes difficult to maintain.
> For example, the Command Line Interface provides both the View
> (what user sees and how they interact with the command line)
> and the Controller (invoking of a command) aspects of a CLI application.
> In Web applications, Controller often manipulates the data (received from the Model)
> before displaying it to the user or passing it from the user to the Model.
>
{: .callout}

### Our Project's Architecture

Our software project uses the MVC architecture.
The file `inflammation-analysis.py` is the **Controller** module
Our software project uses the [Model-View-Controller (MVC) architecture](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller).
MVC architecture divides the software logic into three interconnected modules:

- **Model** (data) - represents the data used by a program and contains operations/rules
for manipulating and changing the data in the model (a database, a file, a single data object
or a series of objects - for example a table representing patients' data).
- **View** (client interface) - provides means of displaying data to users/clients within an
application (i.e. provides visualisation of the state of the model).
For example, displaying a window with input fields and buttons (Graphical User Interface, GUI)
or textual options within a command line (Command Line Interface, CLI) are examples of Views.
- **Controller** (processes that handle input/output and manipulate the data) -
accepts input from the **View** and performs the corresponding action on the **Model**
(changing the state of the model) and then updates the **View** accordingly.

In our project, `inflammation-analysis.py` is the **Controller** module
that performs basic statistical analysis over patient data
and provides the main entry point into the application.
The **View** and **Model** modules are contained in the files `views.py` and `models.py`, respectively,
Expand All @@ -407,7 +315,7 @@ Data underlying the **Model** is contained within the directory `data` -
as we have seen already it contains several files with patients’ daily inflammation information.

We will revisit the software architecture and MVC topics once again in later episodes
when we talk in more detail about [software design](../32-software-design/index.html).
when we talk in more detail about [software architecture and design](../32-software-architecture-design/index.html).
We now proceed to set up our virtual development environment
and start working with the code using a more convenient graphical tool -
[IDE PyCharm](https://www.jetbrains.com/pycharm/).
Expand Down
9 changes: 5 additions & 4 deletions _episodes/12-virtual-environments.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ which contains a particular version of Python installation
plus a number of additional external libraries.

Virtual environments are not just a feature of Python -
most modern programming languages use them to isolate libraries for a specific project
and make it easier to develop, run, test and share code with others.
Even languages that don't explicitly have virtual environments have other mechanisms
that promote per-project library collections.
most modern programming languages use a similar mechanism to isolate libraries or dependencies
for a specific project, making it easier to develop, run, test and share code with others.
Some examples include Bundler for Ruby, Conan for C++, or Maven with classpath for Java.
This can also be achieved with more generic package managers like Spack,
which is used extensively in HPC settings to resolve complex dependencies.
In this episode, we learn how to set up a virtual environment to develop our code
and manage our external dependencies.

Expand Down
Loading