├── .gitignore ├── README.adoc ├── images ├── 3d-modeling.png ├── banner.graffle │ ├── data.plist │ ├── image1.jpg │ ├── image3.png │ └── preview.jpeg ├── banner.png └── reklame.png └── sessions ├── csharp_01 ├── images │ ├── android.png │ ├── azure.png │ ├── cpp.png │ ├── csharp.png │ ├── curriculum-bg.jpg │ ├── devops.png │ ├── dotnet-introduction-bg.jpg │ ├── fsharp.png │ ├── hello-world.png │ ├── ios.png │ ├── ironpython.png │ ├── linux.png │ ├── macos.png │ ├── portrait.jpg │ ├── powershell.png │ ├── red-green-refactor.png │ ├── rpi.png │ ├── shared-branches-bad.png │ ├── test-driven-development.jpg │ ├── thank-you-bg.jpg │ ├── tizen.png │ ├── trunk-based-development-good.png │ ├── trunk-based-development.jpg │ ├── visual-basic.png │ └── windows.png ├── slides.html └── slides.md ├── csharp_02 ├── images │ ├── core.jpg │ ├── generic-cola.jpg │ ├── grain.jpg │ ├── iterator.png │ ├── monkey.jpg │ ├── polymorphism-bg.jpg │ ├── produce-bg.jpg │ ├── robots.jpg │ ├── system-collections-concurrent.png │ ├── system-collections-generic-2.png │ ├── system-collections-generic.png │ ├── system-collections.png │ ├── thank-you.jpg │ └── traffic-lights.jpg ├── slides.html └── slides.md ├── csharp_03 ├── images │ ├── belt.png │ ├── core.jpg │ ├── delegate.jpg │ ├── extensions.jpg │ ├── lambda.png │ ├── questions.jpg │ └── thank-you.jpg ├── slides.html └── slides.md ├── csharp_04 ├── images │ ├── agenda.jpg │ ├── applause.png │ ├── azure-sql.png │ ├── clean-architecture.png │ ├── connection-meme.jpg │ ├── database-popularity.png │ ├── databases.png │ ├── disposable.jpg │ ├── entity-framework-core.jpg │ ├── injection.jpg │ ├── lock.jpg │ ├── model.png │ ├── onion.jpg │ ├── orm.jpg │ ├── package.jpg │ ├── pyramids.jpg │ └── skyscrapers.jpg ├── slides.html └── slides.md ├── csharp_05 ├── images │ └── applause.png ├── slides.html └── slides.md ├── csharp_06 ├── images │ ├── concurrency.jpg │ ├── deadlock.jpg │ ├── funko_pop_collection_by_needxxx_dazxmlc-fullview.jpg │ ├── i-am-a-waiting.png │ ├── main-worker-thread.png │ ├── nails.jpg │ ├── race-condition.png │ ├── stack-heap.png │ └── thread.jpg ├── slides.html └── slides.md ├── csharp_07 ├── images │ ├── 418.png │ ├── mvc-api.png │ └── mvc.png ├── slides.html └── slides.md ├── csharp_08 ├── slides.html └── slides.md ├── csharp_09 ├── images │ ├── angular.png │ ├── react.png │ ├── vue.png │ └── webapps.jpg ├── slides.html └── slides.md ├── csharp_10 ├── images │ ├── ali-farahnak.jpg │ ├── button.png │ └── rip.gif ├── slides.html └── slides.md ├── csharp_11 ├── images │ ├── app-registration-account-types.png │ ├── azure-ad-b2c-identity-providers.png │ ├── binary.jpg │ ├── black-board.jpg │ ├── container.jpg │ ├── lab.gif │ ├── ladle.jpg │ ├── padlock.gif │ └── question.jpg ├── slides.html └── slides.md ├── csharp_12 ├── images │ ├── applause.jpg │ ├── book.gif │ └── questions.png ├── slides.html └── slides.md ├── q_and_a ├── Slides.html └── Slides.md ├── swe_00 └── README.md ├── swe_01 ├── Slides.html ├── Slides.md ├── images │ ├── coronapas_app_arkitektur.png │ ├── coronapas_app_arkitektur2.png │ ├── first_names.png │ └── grades.html └── menti_results.pdf ├── swe_02 ├── Slides.html ├── Slides.md └── images │ ├── analysis.png │ ├── architecture.png │ ├── coronapas_app_arkitektur.png │ ├── design.png │ └── knowledge_maps.png ├── swe_03 ├── Slides.html ├── Slides.md ├── images │ ├── kombit_sapa_krav_148_quiz.png │ ├── kombit_sapa_krav_163_quiz.png │ ├── kombit_sapa_krav_166_quiz.png │ ├── kombit_sapa_krav_180_quiz.png │ ├── kombit_sapa_krav_190_quiz.png │ ├── kombit_sapa_krav_191_quiz.png │ ├── kombit_sapa_krav_1_quiz.png │ ├── kombit_sapa_krav_216_quiz.png │ ├── kombit_sapa_krav_67_quiz.png │ ├── kombit_sapa_use_case.png │ ├── kombit_sapa_use_case_01.png │ ├── kombit_sapa_use_case_02.png │ ├── kombit_sapa_use_case_diagram.png │ ├── kombit_sapa_use_case_diagram2.png │ ├── kombit_sapa_vision.png │ ├── re_process.png │ ├── se_nonfunc.png │ └── use_case_diagram_se.png └── material │ ├── Kravspecifikation juli 2014 v. 1.0.docx │ └── Kravspecifikation juli 2014 v. 1.0.pdf ├── swe_04 ├── Slides.html ├── Slides.md └── images │ ├── Sommerville_activity_diagram.png │ ├── martin_bubble_sort.png │ ├── martin_class_diag.png │ ├── martin_class_diag2.png │ ├── martin_class_diag3.png │ ├── martin_collab_diag.png │ ├── martin_collab_diag2.png │ ├── martin_sequence_diag.png │ └── martin_state_diag.png ├── swe_05 ├── Slides.html ├── Slides.md └── images │ ├── dip_uml_diag.png │ ├── dip_uml_diag.xmi │ ├── lsp_uml_diag.png │ ├── lsp_uml_diag.xmi │ ├── martin_bubble_sort.png │ ├── martin_class_diag.png │ ├── martin_class_diag2.png │ ├── martin_class_diag3.png │ ├── martin_collab_diag.png │ ├── martin_isp.png │ ├── martin_srp_code.png │ ├── martin_srp_diag.png │ ├── ousterhout_complexity.png │ ├── upsource-CR5-OCP-remove-if.png │ ├── upsource-CR5-OCP-remove-if1.png │ └── upsource-CR5-OCP3.png ├── swe_06 ├── Slides.html ├── Slides.md └── images │ ├── Quiz.graffle │ ├── alexander_square.png │ ├── alexander_transport.png │ ├── alexander_transport_areas.png │ ├── dp_paper.png │ ├── facade.png │ ├── gof_command1.png │ ├── gof_command2.png │ ├── gof_observer.png │ ├── gof_observer_case.png │ ├── larman_observer.png │ ├── mediator.png │ ├── mediator_case.png │ ├── observer_dotnet.png │ ├── singleton.png │ └── strategy.png ├── swe_07 ├── Slides.html ├── Slides.md ├── images │ ├── coronapas_app_arkitektur.png │ ├── kombit_sapa_vision.png │ ├── kruchten_4plus1.png │ ├── se_arch.png │ ├── se_client_server_pattern.png │ ├── se_client_server_pattern_fatness.png │ ├── se_component.png │ ├── se_design_decisions.png │ ├── se_distr_comp_arch.png │ ├── se_distr_comp_arch2.png │ ├── se_layered_pattern.png │ ├── se_mvc_pattern.png │ ├── se_mvc_pattern_instance.png │ ├── se_p2p_pattern.png │ ├── se_p2p_pattern2.png │ ├── se_pipes_filters_pattern.png │ └── se_repo_pattern.png └── plot.py ├── swe_08 ├── Slides.html ├── Slides.md ├── bdsa_greeter │ ├── csharp │ │ ├── Program.cs │ │ ├── csharp.csproj │ │ └── dist │ │ │ ├── linux │ │ │ ├── .gitkeep │ │ │ ├── nosc │ │ │ │ └── .gitkeep │ │ │ ├── sc │ │ │ │ └── .gitkeep │ │ │ ├── sf-nosc │ │ │ │ └── .gitkeep │ │ │ └── sf-sc │ │ │ │ └── .gitkeep │ │ │ ├── macos │ │ │ └── .gitkeep │ │ │ └── windows │ │ │ └── .gitkeep │ ├── fpc │ │ └── hello.pas │ ├── go │ │ ├── bdsa_greeter.go │ │ └── dist │ │ │ └── .gitkeep │ └── python │ │ ├── bdsa_greeter │ │ └── cli.py │ │ ├── dist │ │ └── .gitkeep │ │ ├── poetry.lock │ │ └── pyproject.toml ├── hello.dll └── hello.zip ├── swe_09 ├── Slides.html ├── Slides.md └── images │ ├── ISO_25000_internal_qual.png │ ├── SE_TDD.png │ ├── SE_test_process.png │ ├── google_test_antipatterns.png │ ├── google_test_shares.png │ └── google_test_sizes.png ├── swe_10 ├── Slides.html ├── Slides.md └── images │ ├── FSA_arch_characteristics.png │ ├── FSA_overview.png │ ├── ISO_25000.png │ ├── ISO_25010_in_use.png │ ├── ISO_25010_product.png │ ├── ISO_25023.png │ ├── boehm.png │ ├── boehm_metrics.png │ ├── se_metrics.png │ ├── se_oo_metrics.png │ ├── se_qual_attributes.png │ └── se_quality_to_metrics.png ├── swe_11 ├── Slides.html ├── Slides.md └── images │ ├── abstractness.png │ ├── ai_plot.png │ ├── breaking_cycle_input.png │ ├── cycle_dep.png │ ├── deps.png │ ├── gitinsight_components.png │ ├── graph.svg │ ├── instability.png │ ├── pino_npm.png │ └── vcpkg_gephi.png ├── swe_12 ├── Slides.html ├── Slides.md ├── images │ ├── agilemanifesto.png │ ├── helena_paper.png │ ├── royce_waterfall_model1.png │ ├── royce_waterfall_model2.png │ ├── royce_waterfall_model3.png │ ├── royce_waterfall_model4.png │ ├── se_agile_principles.png │ ├── se_extreme_cycle.png │ ├── se_extreme_practices.png │ ├── se_iterative.png │ ├── se_iterative_dev.png │ ├── se_userstory.png │ ├── se_waterfall_model.png │ ├── statens_it_model.png │ └── statens_it_model2.png └── project_demo.md ├── the_gilded_rose ├── images │ └── gilded-rose.jpg ├── slides.html └── slides.md └── the_gilded_rose_recap ├── images └── gilded-rose.jpg ├── slides.html └── slides.md /.gitignore: -------------------------------------------------------------------------------- 1 | [Ss]lides.pdf 2 | 3 | ## Ignore Visual Studio temporary files, build results, and 4 | ## files generated by popular Visual Studio add-ons. 5 | ## 6 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 7 | 8 | # User-specific files 9 | *.rsuser 10 | *.suo 11 | *.user 12 | *.userosscache 13 | *.sln.docstates 14 | 15 | # User-specific files (MonoDevelop/Xamarin Studio) 16 | *.userprefs 17 | 18 | # Mono auto generated files 19 | mono_crash.* 20 | 21 | # Build results 22 | [Dd]ebug/ 23 | [Dd]ebugPublic/ 24 | [Rr]elease/ 25 | [Rr]eleases/ 26 | x64/ 27 | x86/ 28 | [Aa][Rr][Mm]/ 29 | [Aa][Rr][Mm]64/ 30 | bld/ 31 | [Bb]in/ 32 | [Oo]bj/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # StyleCop 67 | StyleCopReport.xml 68 | 69 | # Files built by Visual Studio 70 | *_i.c 71 | *_p.c 72 | *_h.h 73 | *.ilk 74 | *.meta 75 | *.obj 76 | *.iobj 77 | *.pch 78 | *.pdb 79 | *.ipdb 80 | *.pgc 81 | *.pgd 82 | *.rsp 83 | *.sbr 84 | *.tlb 85 | *.tli 86 | *.tlh 87 | *.tmp 88 | *.tmp_proj 89 | *_wpftmp.csproj 90 | *.log 91 | *.vspscc 92 | *.vssscc 93 | .builds 94 | *.pidb 95 | *.svclog 96 | *.scc 97 | 98 | # Chutzpah Test files 99 | _Chutzpah* 100 | 101 | # Visual C++ cache files 102 | ipch/ 103 | *.aps 104 | *.ncb 105 | *.opendb 106 | *.opensdf 107 | *.sdf 108 | *.cachefile 109 | *.VC.db 110 | *.VC.VC.opendb 111 | 112 | # Visual Studio profiler 113 | *.psess 114 | *.vsp 115 | *.vspx 116 | *.sap 117 | 118 | # Visual Studio Trace Files 119 | *.e2e 120 | 121 | # TFS 2012 Local Workspace 122 | $tf/ 123 | 124 | # Guidance Automation Toolkit 125 | *.gpState 126 | 127 | # ReSharper is a .NET coding add-in 128 | _ReSharper*/ 129 | *.[Rr]e[Ss]harper 130 | *.DotSettings.user 131 | 132 | # TeamCity is a build add-in 133 | _TeamCity* 134 | 135 | # DotCover is a Code Coverage Tool 136 | *.dotCover 137 | 138 | # AxoCover is a Code Coverage Tool 139 | .axoCover/* 140 | !.axoCover/settings.json 141 | 142 | # Visual Studio code coverage results 143 | *.coverage 144 | *.coveragexml 145 | 146 | # NCrunch 147 | _NCrunch_* 148 | .*crunch*.local.xml 149 | nCrunchTemp_* 150 | 151 | # MightyMoose 152 | *.mm.* 153 | AutoTest.Net/ 154 | 155 | # Web workbench (sass) 156 | .sass-cache/ 157 | 158 | # Installshield output folder 159 | [Ee]xpress/ 160 | 161 | # DocProject is a documentation generator add-in 162 | DocProject/buildhelp/ 163 | DocProject/Help/*.HxT 164 | DocProject/Help/*.HxC 165 | DocProject/Help/*.hhc 166 | DocProject/Help/*.hhk 167 | DocProject/Help/*.hhp 168 | DocProject/Help/Html2 169 | DocProject/Help/html 170 | 171 | # Click-Once directory 172 | publish/ 173 | 174 | # Publish Web Output 175 | *.[Pp]ublish.xml 176 | *.azurePubxml 177 | # Note: Comment the next line if you want to checkin your web deploy settings, 178 | # but database connection strings (with potential passwords) will be unencrypted 179 | *.pubxml 180 | *.publishproj 181 | 182 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 183 | # checkin your Azure Web App publish settings, but sensitive information contained 184 | # in these scripts will be unencrypted 185 | PublishScripts/ 186 | 187 | # NuGet Packages 188 | *.nupkg 189 | # NuGet Symbol Packages 190 | *.snupkg 191 | # The packages folder can be ignored because of Package Restore 192 | **/[Pp]ackages/* 193 | # except build/, which is used as an MSBuild target. 194 | !**/[Pp]ackages/build/ 195 | # Uncomment if necessary however generally it will be regenerated when needed 196 | #!**/[Pp]ackages/repositories.config 197 | # NuGet v3's project.json files produces more ignorable files 198 | *.nuget.props 199 | *.nuget.targets 200 | 201 | # Microsoft Azure Build Output 202 | csx/ 203 | *.build.csdef 204 | 205 | # Microsoft Azure Emulator 206 | ecf/ 207 | rcf/ 208 | 209 | # Windows Store app package directories and files 210 | AppPackages/ 211 | BundleArtifacts/ 212 | Package.StoreAssociation.xml 213 | _pkginfo.txt 214 | *.appx 215 | *.appxbundle 216 | *.appxupload 217 | 218 | # Visual Studio cache files 219 | # files ending in .cache can be ignored 220 | *.[Cc]ache 221 | # but keep track of directories ending in .cache 222 | !?*.[Cc]ache/ 223 | 224 | # Others 225 | ClientBin/ 226 | ~$* 227 | *~ 228 | *.dbmdl 229 | *.dbproj.schemaview 230 | *.jfm 231 | *.pfx 232 | *.publishsettings 233 | orleans.codegen.cs 234 | 235 | # Including strong name files can present a security risk 236 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 237 | #*.snk 238 | 239 | # Since there are multiple workflows, uncomment next line to ignore bower_components 240 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 241 | #bower_components/ 242 | 243 | # RIA/Silverlight projects 244 | Generated_Code/ 245 | 246 | # Backup & report files from converting an old project file 247 | # to a newer Visual Studio version. Backup files are not needed, 248 | # because we have git ;-) 249 | _UpgradeReport_Files/ 250 | Backup*/ 251 | UpgradeLog*.XML 252 | UpgradeLog*.htm 253 | ServiceFabricBackup/ 254 | *.rptproj.bak 255 | 256 | # SQL Server files 257 | *.mdf 258 | *.ldf 259 | *.ndf 260 | 261 | # Business Intelligence projects 262 | *.rdl.data 263 | *.bim.layout 264 | *.bim_*.settings 265 | *.rptproj.rsuser 266 | *- [Bb]ackup.rdl 267 | *- [Bb]ackup ([0-9]).rdl 268 | *- [Bb]ackup ([0-9][0-9]).rdl 269 | 270 | # Microsoft Fakes 271 | FakesAssemblies/ 272 | 273 | # GhostDoc plugin setting file 274 | *.GhostDoc.xml 275 | 276 | # Node.js Tools for Visual Studio 277 | .ntvs_analysis.dat 278 | node_modules/ 279 | 280 | # Visual Studio 6 build log 281 | *.plg 282 | 283 | # Visual Studio 6 workspace options file 284 | *.opt 285 | 286 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 287 | *.vbw 288 | 289 | # Visual Studio LightSwitch build output 290 | **/*.HTMLClient/GeneratedArtifacts 291 | **/*.DesktopClient/GeneratedArtifacts 292 | **/*.DesktopClient/ModelManifest.xml 293 | **/*.Server/GeneratedArtifacts 294 | **/*.Server/ModelManifest.xml 295 | _Pvt_Extensions 296 | 297 | # Paket dependency manager 298 | .paket/paket.exe 299 | paket-files/ 300 | 301 | # FAKE - F# Make 302 | .fake/ 303 | 304 | # CodeRush personal settings 305 | .cr/personal 306 | 307 | # Python Tools for Visual Studio (PTVS) 308 | __pycache__/ 309 | *.pyc 310 | 311 | # Cake - Uncomment if you are using it 312 | # tools/** 313 | # !tools/packages.config 314 | 315 | # Tabs Studio 316 | *.tss 317 | 318 | # Telerik's JustMock configuration file 319 | *.jmconfig 320 | 321 | # BizTalk build output 322 | *.btp.cs 323 | *.btm.cs 324 | *.odx.cs 325 | *.xsd.cs 326 | 327 | # OpenCover UI analysis results 328 | OpenCover/ 329 | 330 | # Azure Stream Analytics local run output 331 | ASALocalRun/ 332 | 333 | # MSBuild Binary and Structured Log 334 | *.binlog 335 | 336 | # NVidia Nsight GPU debugger configuration file 337 | *.nvuser 338 | 339 | # MFractors (Xamarin productivity tool) working folder 340 | .mfractor/ 341 | 342 | # Local History for Visual Studio 343 | .localhistory/ 344 | 345 | # BeatPulse healthcheck temp database 346 | healthchecksdb 347 | 348 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 349 | MigrationBackup/ 350 | 351 | # Ionide (cross platform F# VS Code tools) working folder 352 | .ionide/ 353 | 354 | .DS_Store 355 | .vscode 356 | index.html 357 | misc/students/courseid_*_participants.csv 358 | README_LearnIT.html 359 | sessions/swe_*/Slides.pdf 360 | 361 | tmp/ 362 | misc/communication/*.html 363 | README.html 364 | -------------------------------------------------------------------------------- /images/3d-modeling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/images/3d-modeling.png -------------------------------------------------------------------------------- /images/banner.graffle/data.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/images/banner.graffle/data.plist -------------------------------------------------------------------------------- /images/banner.graffle/image1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/images/banner.graffle/image1.jpg -------------------------------------------------------------------------------- /images/banner.graffle/image3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/images/banner.graffle/image3.png -------------------------------------------------------------------------------- /images/banner.graffle/preview.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/images/banner.graffle/preview.jpeg -------------------------------------------------------------------------------- /images/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/images/banner.png -------------------------------------------------------------------------------- /images/reklame.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/images/reklame.png -------------------------------------------------------------------------------- /sessions/csharp_01/images/android.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_01/images/android.png -------------------------------------------------------------------------------- /sessions/csharp_01/images/azure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_01/images/azure.png -------------------------------------------------------------------------------- /sessions/csharp_01/images/cpp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_01/images/cpp.png -------------------------------------------------------------------------------- /sessions/csharp_01/images/csharp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_01/images/csharp.png -------------------------------------------------------------------------------- /sessions/csharp_01/images/curriculum-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_01/images/curriculum-bg.jpg -------------------------------------------------------------------------------- /sessions/csharp_01/images/devops.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_01/images/devops.png -------------------------------------------------------------------------------- /sessions/csharp_01/images/dotnet-introduction-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_01/images/dotnet-introduction-bg.jpg -------------------------------------------------------------------------------- /sessions/csharp_01/images/fsharp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_01/images/fsharp.png -------------------------------------------------------------------------------- /sessions/csharp_01/images/hello-world.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_01/images/hello-world.png -------------------------------------------------------------------------------- /sessions/csharp_01/images/ios.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_01/images/ios.png -------------------------------------------------------------------------------- /sessions/csharp_01/images/ironpython.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_01/images/ironpython.png -------------------------------------------------------------------------------- /sessions/csharp_01/images/linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_01/images/linux.png -------------------------------------------------------------------------------- /sessions/csharp_01/images/macos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_01/images/macos.png -------------------------------------------------------------------------------- /sessions/csharp_01/images/portrait.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_01/images/portrait.jpg -------------------------------------------------------------------------------- /sessions/csharp_01/images/powershell.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_01/images/powershell.png -------------------------------------------------------------------------------- /sessions/csharp_01/images/red-green-refactor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_01/images/red-green-refactor.png -------------------------------------------------------------------------------- /sessions/csharp_01/images/rpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_01/images/rpi.png -------------------------------------------------------------------------------- /sessions/csharp_01/images/shared-branches-bad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_01/images/shared-branches-bad.png -------------------------------------------------------------------------------- /sessions/csharp_01/images/test-driven-development.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_01/images/test-driven-development.jpg -------------------------------------------------------------------------------- /sessions/csharp_01/images/thank-you-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_01/images/thank-you-bg.jpg -------------------------------------------------------------------------------- /sessions/csharp_01/images/tizen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_01/images/tizen.png -------------------------------------------------------------------------------- /sessions/csharp_01/images/trunk-based-development-good.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_01/images/trunk-based-development-good.png -------------------------------------------------------------------------------- /sessions/csharp_01/images/trunk-based-development.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_01/images/trunk-based-development.jpg -------------------------------------------------------------------------------- /sessions/csharp_01/images/visual-basic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_01/images/visual-basic.png -------------------------------------------------------------------------------- /sessions/csharp_01/images/windows.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_01/images/windows.png -------------------------------------------------------------------------------- /sessions/csharp_01/slides.md: -------------------------------------------------------------------------------- 1 | --- 2 | marp: true 3 | author: Rasmus Lystrøm 4 | theme: default 5 | class: invert 6 | --- 7 | 8 | 17 | 18 |
19 | 20 | # C♯ 01: Test Driven C♯ 21 | 22 | ![bg blur:1px](images/hello-world.png) 23 | 24 | Rasmus Lystrøm 25 | Associate Professor 26 | ITU 27 | 28 |
29 | 30 | --- 31 | 32 | # About Me 33 | 34 | ![bg right:18%](images/portrait.jpg) 35 | 36 | Senior Cloud Solution Architect @ Microsoft 37 | Associate Professer @ ITU 38 | Captain/Battalion Chief of Staff @ Danish Army (Reserves) 39 | 40 | M[]().Sc. IT, ITU (2012) 41 | Thesis: *Forecalc – Developing a core spreadsheet implementation in F♯* 42 | 43 | Wife: Katrine 44 | Children: Lærke (4), Laura (7), and Alma (14) 45 | Origin: Aarhus 46 | Currently residing: Vanløse (Copenhagen) 47 | 48 | Live music and festivals (Copenhell, Brutal Assault, Hellfest, etc.) 49 | Cross-fit 50 | 51 | --- 52 | 53 | # Agenda 54 | 55 | - How to reach me 56 | - *Boring stuff* 57 | - Test-Driven Development 58 | - Trunk Based Development 59 | - Continuous Integration 60 | - Show and Tell 61 | 62 | --- 63 | 64 | # How to reach me 65 | 66 | Do not write me an email! 67 | Use Discord: the TAs or your fellow students might have the answer. 68 | You may tag me. 69 | You may DM me for personal questions. 70 | 71 | --- 72 | 73 | # Curriculum 74 | 75 | ![bg](images/curriculum-bg.jpg) 76 | 77 | Test-Driven C♯ 78 | Generics 79 | Lambdas and Linq 80 | Data Access (ORM) 81 | Asynchronous and Parallel 82 | Web APIs 83 | Design Patterns 84 | Mobile and Desktop Apps 85 | Web apps 86 | Security 87 | Cloud 88 | 89 | Updated version cf. 90 | 91 | --- 92 | 93 | # C♯ 94 | 95 | > "C♯ is intended to be a simple, modern, general-purpose, object-oriented programming language." 96 | 97 | ECMA-334 ISO/IEC 23270:2018(E) 98 | C♯ language specification, 5th edition, December 2017 99 | 100 | --- 101 | 102 | # Why C♯ 103 | 104 | - Popular cf. [Stack Overflow Annual Developer Survey 2022](https://survey.stackoverflow.co/2022/) 105 | - Ubiquitous 106 | - Open Source 107 | - Cross-platform 108 | - Industry / Enterprise 109 | - Tool for your toolbox 110 | - IRON 111 | - .NET CLR 112 | 113 | --- 114 | 115 | # Why not C♯ 116 | 117 | ## It's just like Java 118 | 119 | - Curly brackets and semicolons from C 120 | - Statically typed 121 | - Object-oriented 122 | - Single inheritance 123 | - Cross platform 124 | - Open source 125 | - Industry / enterprise 126 | - JVM 127 | 128 | --- 129 | 130 | # Enterprise 131 | 132 | 133 | 134 | 135 | 136 | --- 137 | 138 | # Build on what you know already 139 | 140 | - No basic stuff 141 | - Read the book 142 | - Do the exercises 143 | - Learn the advanced patterns and syntactic sugar 144 | - Idiomatic C♯ 145 | - Focus on clean, testable code 146 | - Stop the enterprise madness! 147 | 148 | --- 149 | 150 | ![bg](images/dotnet-introduction-bg.jpg) 151 | 152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 | 165 | # .NET - a brief introduction 166 | 167 | --- 168 | 169 | # .NET 170 | 171 | > .NET is a free, cross-platform, open source developer platform for building many different types of applications. 172 | 173 | > With .NET, you can use multiple languages, editors, and libraries to build for web, mobile, desktop, games, IoT, and more. 174 | 175 | 176 | 177 | --- 178 | 179 | 180 | 181 | ![bg width:200px](images/csharp.png) 182 | ![bg width:150px](images/fsharp.png) 183 | ![bg width:150px](images/visual-basic.png) 184 | ![bg width:150px](images/powershell.png) 185 | ![bg width:125px](images/cpp.png) 186 | ![bg width:150px](images/ironpython.png) 187 | 188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 | 198 | # .NET Languages 199 | 200 | 201 | 202 | --- 203 | 204 | 205 | 206 | ![bg width:125px](images/windows.png) 207 | ![bg width:125px](images/macos.png) 208 | ![bg width:125px](images/linux.png) 209 | ![bg width:125px](images/ios.png) 210 | ![bg width:125px](images/android.png) 211 | ![bg width:125px](images/rpi.png) 212 | ![bg width:125px](images/tizen.png) 213 | ![bg width:125px](images/azure.png) 214 | 215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 | 225 | # .NET Platforms 226 | 227 | --- 228 | 229 | # .NET Timeline 230 | 231 | 2002: .NET, C♯, Visual Basic, Visual Studio .NET 232 | 2003: .NET 1.1, Visual Studio .NET 2003 233 | 2005: .NET 2.0, C♯ 2, F♯, Generics, VS2005 234 | 2007: .NET 3.5, C♯ 3, Auto-properties, Linq, Lambda, VS2008 235 | 2010: .NET 4.0, C♯ 4, F♯ 2, Dynamic, Parallel, VS2010 236 | 2012: .NET 4.5, C♯ 5, F♯ 3, Async/await, VS2012 237 | 2015: .NET 4.6, C♯ 6, F♯ 4, VS2015 238 | 2016: **.NET Core**, Open Source on GitHub!, Visual Studio Code 239 | 2017: .NET 4.7, **.NET Core 2**, C♯ 7, VS2017 240 | 2019: .NET 4.8, **.NET Core 3**, C♯ 8, VS2019 241 | 2020: **.NET 5**, C♯ 9, F♯ 5 242 | 2021: **.NET 6**, C♯ 10, F♯ 6 243 | 2022: **.NET 7**, C♯ 11, [.NET Conf 2022 8-10 November](https://www.dotnetconf.net/) 244 | 245 | --- 246 | 247 | 248 | 249 | ![bg](images/test-driven-development.jpg) 250 | 251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 | 264 | # Test-Driven Development 265 | 266 | --- 267 | 268 | # Test-Driven Development 269 | 270 | - What? 271 | - Why? 272 | - How? 273 | 274 | --- 275 | 276 | 277 | 278 | ![bg contain](images/red-green-refactor.png) 279 | 280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 | 294 | # Red-Green-Refactor 295 | 296 | --- 297 | 298 | ![bg](images/trunk-based-development.jpg) 299 | 300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 | 313 | # Trunk Based Development 314 | 315 | --- 316 | 317 | # Trunk Based Development - What? 318 | 319 | > A source-control branching model, where developers collaborate on code in a single branch called 'trunk'*), resist any pressure to create other long-lived development branches by employing documented techniques. They therefore avoid merge hell, do not break the build, and live happily ever after. 320 | 321 | *) master/main, in Git nomenclature 322 | 323 | Source: 324 | 325 | --- 326 | 327 | 328 | 329 | # Shared branches off mainline/master/trunk are bad at any release cadence 330 | 331 | ![width:1200](images/shared-branches-bad.png) 332 | 333 | --- 334 | 335 | 336 | 337 | # Trunk Based Development – How? 338 | 339 | ![width:1200](images/trunk-based-development-good.png) 340 | 341 | --- 342 | 343 | # Branching strategy 344 | 345 | - Short-lived < 1 day 346 | - Branching enables automated tests as gates 347 | - It's not a *strategy*... 348 | 349 | --- 350 | 351 | ![bg contain](images/devops.png) 352 | 353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 | 367 | # Continuous Integration 368 | 369 | --- 370 | 371 | # Continuous Integration – What? 372 | 373 | > Continuous Integration (CI) is the process of automating the build and testing of code every time a team member commits changes to version control. 374 | 375 | Source: 376 | 377 | --- 378 | 379 | # Demo 380 | 381 | Test-Driven C♯ using Continuous Integration and Trunk Based Development 382 | 383 | --- 384 | 385 | ![bg contain](images/thank-you-bg.jpg) 386 | 387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 | 400 | # Thank you 401 | 402 | --- 403 | 404 | # Appendix 405 | 406 | --- 407 | 408 | # Create a C♯ console app with a test library 409 | 410 | ```bash 411 | mkdir MyApp 412 | cd MyApp 413 | 414 | dotnet new console -o MyApp 415 | dotnet new xunit -o MyApp.Tests 416 | 417 | dotnet new sln 418 | dotnet sln add MyApp 419 | dotnet sln add MyApp.Tests 420 | dotnet add MyApp.Tests reference MyApp 421 | 422 | dotnet build 423 | dotnet test 424 | dotnet run --project MyApp 425 | 426 | dotnet list package --outdated 427 | dotnet add MyApp.Tests package xunit # add/update package 428 | 429 | dotnet watch test --project HelloWorld.Tests/ 430 | ``` 431 | 432 | --- 433 | 434 | # The C♯ class 435 | 436 | ```csharp 437 | namespace Namespace; 438 | 439 | public class Class 440 | { 441 |     private string _field; 442 |          443 | protected DateTime _fieldAvailableInSubClass; 444 |          445 | public string Property { get => _field; } // Getter 446 |          447 | public int AutoProperty { get; set; } 448 |          449 | public Class() { } 450 | 451 | public string InstanceMethod(string parameter) 452 |     { 453 |         return $"Hello {parameter}"; 454 |     } 455 | 456 |     public virtual bool OverridableInstanceMethod(bool parameter) => !parameter; 457 | 458 |     public static void StaticMethod() { } 459 |         460 | private void PrivateInstanceMethod() { } 461 | 462 | public event EventHandler Event; 463 | 464 | protected virtual void OnEvent(EventArgs e) 465 |     { 466 |         EventHandler handler = Event; 467 |         handler?.Invoke(this, e); 468 |     } 469 | 470 | public delegate void MyEventHandler(object sender, EventArgs e); 471 | } 472 | ``` 473 | 474 | --- 475 | 476 | # Naming Conventions 477 | 478 | **Composed names** 479 | `currentLayout`, `CurrentLayout` 480 | 481 | **Variables and fields** 482 | `vehicle`, `leftElement` 483 | 484 | **Private fields** 485 | `_vehicle`, `_leftElement` 486 | 487 | **Methods** 488 | `CurrentVehicle()`, `Size()` 489 | 490 | **Properties** 491 | `Pi`, `Name`, `Size` 492 | 493 | **Classes** 494 | `MyClass`, `List` 495 | 496 | **Interfaces** 497 | `IException`, `IObserver` 498 | 499 | 500 | 501 | --- 502 | 503 | # Built-in Types 504 | 505 | ```csharp 506 | bool boolean; // true || false 507 | char character;  // 'a', 'b', 'c', '1', '2', '3'  508 | 509 | // Integral numeric types 510 | byte integer8bit; sbyte signedByte; 511 | int integer32bit;         uint unsignedInteger32bit; 512 | long integer64bit;         ulong unsignedInteger64bit; 513 | short integer16bit;         ushort unsignedInteger16bit; 514 | 515 | // Floating point numeric types Reference types 516 | decimal precisionFloatingPoint; object obj; 517 | double floatingPoint64bit; string str; 518 | float floatingPoint32Bit; dynamic dyn; 519 | ``` 520 | 521 | 522 | 523 | --- 524 | 525 | # Basic Unit Test 526 | 527 | ```csharp 528 | public class Ticker 529 | { 530 |     public int Counter { get; private set; } 531 |     public void Increment() => Counter++; 532 | public Ticker(int start = 0) => Counter = start; 533 | } 534 | 535 | public class TickerTests 536 | { 537 |     [Fact] 538 |     public void Increment_when_called_increases_Counter_by_1() 539 |     { 540 |         // Arrange 541 |         var sut = new Ticker(41); 542 | 543 |         // Act 544 |         sut.Increment(); 545 | 546 |        // Assert 547 |         sut.Counter.Should().Be(42); 548 |     } 549 | } 550 | ``` -------------------------------------------------------------------------------- /sessions/csharp_02/images/core.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_02/images/core.jpg -------------------------------------------------------------------------------- /sessions/csharp_02/images/generic-cola.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_02/images/generic-cola.jpg -------------------------------------------------------------------------------- /sessions/csharp_02/images/grain.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_02/images/grain.jpg -------------------------------------------------------------------------------- /sessions/csharp_02/images/iterator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_02/images/iterator.png -------------------------------------------------------------------------------- /sessions/csharp_02/images/monkey.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_02/images/monkey.jpg -------------------------------------------------------------------------------- /sessions/csharp_02/images/polymorphism-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_02/images/polymorphism-bg.jpg -------------------------------------------------------------------------------- /sessions/csharp_02/images/produce-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_02/images/produce-bg.jpg -------------------------------------------------------------------------------- /sessions/csharp_02/images/robots.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_02/images/robots.jpg -------------------------------------------------------------------------------- /sessions/csharp_02/images/system-collections-concurrent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_02/images/system-collections-concurrent.png -------------------------------------------------------------------------------- /sessions/csharp_02/images/system-collections-generic-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_02/images/system-collections-generic-2.png -------------------------------------------------------------------------------- /sessions/csharp_02/images/system-collections-generic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_02/images/system-collections-generic.png -------------------------------------------------------------------------------- /sessions/csharp_02/images/system-collections.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_02/images/system-collections.png -------------------------------------------------------------------------------- /sessions/csharp_02/images/thank-you.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_02/images/thank-you.jpg -------------------------------------------------------------------------------- /sessions/csharp_02/images/traffic-lights.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_02/images/traffic-lights.jpg -------------------------------------------------------------------------------- /sessions/csharp_02/slides.md: -------------------------------------------------------------------------------- 1 | --- 2 | marp: true 3 | author: Rasmus Lystrøm 4 | theme: default 5 | class: invert 6 | --- 7 | 8 | # C♯ 02: Generics, Collections, Iterators, and Regular Expressions 9 | 10 | ![bg right:50% contain](images/generic-cola.jpg) 11 | 12 | Rasmus Lystrøm 13 | Associate Professor 14 | ITU 15 | 16 | --- 17 | 18 | 19 | 20 | ![bg blur:1px](images/polymorphism-bg.jpg) 21 | 22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | 33 | # Parametric Polymorphism – "Generics" 34 | 35 | --- 36 | 37 | # Generics 38 | 39 | ![bg right:60%](images/core.jpg) 40 | 41 | Collections (Generic) 42 | Iterators 43 | Create your own? 44 | Type Constraints 45 | (Co- and contravariance) 46 | 47 | --- 48 | 49 | # `ArrayList` --> `List` 50 | 51 | ```csharp 52 | // Non-generic 53 | IList list = new ArrayList(); 54 | list.Add("hello"); 55 | var s = (string)list[0]; 56 | 57 | // Generic 58 | IList list = new List(); 59 | list.Add("hello"); 60 | var s = list[0]; 61 | ``` 62 | 63 | --- 64 | 65 | ![bg](images/robots.jpg) 66 | 67 | # Generic collections 68 | 69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | 82 | --- 83 | 84 | 85 | 86 | # `System.Collections` 87 | 88 | ![](images/system-collections.png) 89 | 90 | --- 91 | 92 | 93 | 94 | # `System.Collections.Generic` 95 | 96 | ![](images/system-collections-generic.png) 97 | 98 | --- 99 | 100 | 101 | 102 | # `System.Collections.Generic` - Key/Value 103 | 104 | ![](images/system-collections-generic-2.png) 105 | 106 | --- 107 | 108 | 109 | 110 | # `System.Collections.Concurrent` 111 | 112 | ![](images/system-collections-concurrent.png) 113 | 114 | --- 115 | 116 | # Generic Collections 117 | 118 | ## Demo 119 | 120 | --- 121 | 122 | ![bg](images/produce-bg.jpg) 123 | 124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 | 137 | # Iterators 138 | 139 | --- 140 | 141 | 142 | 143 | # Iterators 144 | 145 | ![bg right:50% contain](images/iterator.png) 146 | 147 | - Producer 148 | - Building block for *LINQ* 149 | - Enables: 150 | 151 | ```csharp 152 | foreach (var item in items) 153 | { 154 | Console.WriteLine(item.Name); 155 | } 156 | ``` 157 | 158 | - Built using: 159 | 160 | ``` 161 | yield return 42; 162 | yield break; 163 | ``` 164 | 165 | --- 166 | 167 | # Iterators 168 | 169 | ## Demo 170 | 171 | --- 172 | 173 | # Create your own generic class 174 | 175 | ```csharp 176 | class MyGenericClass where T : IComparable 177 | { 178 |     void Add(T value) { } 179 |     void Remove(T value) { } 180 |     bool Contains(T value) { } 181 | } 182 | ``` 183 | 184 | --- 185 | 186 | # Create your own generic class 2 187 | 188 | ```csharp 189 | class MyGenericMap 190 | { 191 |     void Add(TKey key, TValue value) { } 192 |     bool ContainsKey(TKey key) { } 193 |     bool ContainsValue(TValue key) { } 194 |     TValue this[TKey key] { get; set; } 195 | } 196 | ``` 197 | 198 | --- 199 | 200 | # Create your own generic method 201 | 202 | ```csharp 203 | public string Serialize(T obj) {} 204 | 205 | public T2 Convert(T1 obj) { } 206 | ``` 207 | 208 | --- 209 | 210 | # Type constraints 211 | 212 | ```csharp 213 | public class MyConstrainedGenericClass  214 |     where T : class, new() { } 215 | 216 | public class MyConstrainedGenericClass  217 |     where T : struct { } 218 | 219 | public class MyConstrainedGenericClass  220 |     where T1 : Foo  221 | where T2 : IBar { } 222 | 223 | public T2 MyConstrainedMethod(T1 item) 224 |     where T1 : Foo 225 |     where T2 : IBar, new() { } 226 | ``` 227 | 228 | --- 229 | 230 | # Custom Generics 231 | 232 | ## Demo 233 | 234 | --- 235 | 236 | ![bg](images/grain.jpg) 237 | 238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 | 251 | # Covariance – Contravariance – Invariance? 252 | 253 | --- 254 | 255 | ### Covariance 256 | 257 | Enables you to use a more derived type than originally specified. 258 | You can assign an instance of `IEnumerable` to a variable of type `IEnumerable`. 259 | 260 | ### Contravariance 261 | 262 | Enables you to use a more generic (less derived) type than originally specified. 263 | You can assign an instance of `Action` to a variable of type `Action`. 264 | 265 | ### Invariance 266 | 267 | Means that you can use only the type originally specified. An invariant generic type parameter is neither covariant nor contravariant. 268 | You cannot assign an instance of `List` to a variable of type `List` or vice versa. 269 | 270 | Source: [docs.microsoft.com/.../generics/covariance-and-contravariance](https://docs.microsoft.com/en-us/dotnet/standard/generics/covariance-and-contravariance). 271 | 272 | --- 273 | 274 | # Built-in Generics 275 | 276 | ```csharp 277 | public interface IComparer 278 | { 279 |     int Compare(T x, T y); 280 | } 281 | 282 | public interface IEnumerable : IEnumerable 283 | { 284 |     IEnumerator GetEnumerator(); 285 | } 286 | ``` 287 | 288 | --- 289 | 290 | # Covariance and Contravariance 291 | 292 | ## Demo 293 | 294 | --- 295 | 296 | ![bg](images/traffic-lights.jpg) 297 | 298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 | 312 | # Enumerations 313 | 314 | --- 315 | 316 | # Enumerations 317 | 318 | ## Demo 319 | 320 | Source: [docs.microsoft.com/.../language-reference/builtin-types/enum](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/enum) 321 | 322 | --- 323 | 324 | ![bg](images/monkey.jpg) 325 | 326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 | 340 | # Regular Expressions 341 | 342 | --- 343 | 344 | # Regular Expressions reference 1 345 | 346 | `*` Zero or more times the previous character 347 | `+` Once or more times the previous character 348 | `?` Zero or one time the previous character 349 | `.` Any single character (not \n) 350 | `\s` Any whitespace character (e.g. tab) 351 | `\S` Any non-whitespace character 352 | `\b` Word boundary 353 | `\B` Any non-word boundary position 354 | `\w` Any word character (a-z, A-Z, 0-9) 355 | `\W` Any non-word character 356 | `^` Start of the input text 357 | `$` End of the input text 358 | 359 | --- 360 | 361 | # Regular Expressions reference 2 362 | 363 | `[1c]` matches character ‘1’ or ‘c’ 364 | `[a-z]` matches all lower-case letters 365 | `[a-zA-Z]` matches all letters 366 | `[0-9]+` matches integer numbers 367 | `[0-9]+\.[0-9]+` matches a floating point 368 | `[0-2][0-9]:[0-5][0-9]` matches a time e.g. 12:34 369 | 370 | --- 371 | 372 | # Regular Expressions reference 3 373 | 374 | `[^abc]` matches character not in ‘a’, ‘b’, or ‘c’ 375 | `(capture)` capturing group 376 | `(?:non)` non-capturing group 377 | `(?name)` named capturing group 378 | `[a-z]+(\d{5})` matches a standard Danish license plate where the numeric part is a capturing group 379 | `(?\w+) (?\w+)` matching a given name followed by a surname (named capturing groups) 380 | `(?:Jane|John) (\w+) (?:Doe)` matching the middle name of Jane or John Doe 381 | 382 | --- 383 | 384 | # Regular Expressions 385 | 386 | ## Demo 387 | 388 | --- 389 | 390 | ![bg](images/thank-you.jpg) 391 | 392 | # Thank you 393 | 394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 | -------------------------------------------------------------------------------- /sessions/csharp_03/images/belt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_03/images/belt.png -------------------------------------------------------------------------------- /sessions/csharp_03/images/core.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_03/images/core.jpg -------------------------------------------------------------------------------- /sessions/csharp_03/images/delegate.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_03/images/delegate.jpg -------------------------------------------------------------------------------- /sessions/csharp_03/images/extensions.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_03/images/extensions.jpg -------------------------------------------------------------------------------- /sessions/csharp_03/images/lambda.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_03/images/lambda.png -------------------------------------------------------------------------------- /sessions/csharp_03/images/questions.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_03/images/questions.jpg -------------------------------------------------------------------------------- /sessions/csharp_03/images/thank-you.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_03/images/thank-you.jpg -------------------------------------------------------------------------------- /sessions/csharp_03/slides.md: -------------------------------------------------------------------------------- 1 | --- 2 | marp: true 3 | author: Rasmus Lystrøm 4 | theme: default 5 | class: invert 6 | --- 7 | 8 | # Survey during the *academic quarter* 9 | 10 | ## code: `5942 1139` 11 | 12 | --- 13 | 14 | # Questions 15 | 16 | - How to setup tests? 17 | - Testing private methods? 18 | - How to use fluent assertions? 19 | 20 | --- 21 | 22 | # C♯ 03: Lambdas and LINQ 23 | 24 | ![bg right:50%](images/lambda.png) 25 | 26 | Rasmus Lystrøm 27 | Associate Professor 28 | ITU 29 | 30 | --- 31 | 32 | # Topics 33 | 34 | ![bg right:60%](images/core.jpg) 35 | 36 | Delegates 37 | Anonymous methods 38 | Lambda expressions 39 | Local functions 40 | Anonymous types 41 | Tuples 42 | Records 43 | Extension methods 44 | LINQ 45 | 46 | --- 47 | 48 | ![bg](images/delegate.jpg) 49 | 50 | # Delegates 51 | 52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | 65 | --- 66 | 67 | 68 | 69 | # Delegates – Building block for Higher-order functions 70 | 71 | ```csharp 72 | public delegate int BinaryOperation(int x, int y); 73 | 74 | var add = new BinaryOperation( 75 |     delegate (int x, int y) 76 |     { 77 |         return x + y; 78 |     } 79 | ); 80 | ``` 81 | 82 | --- 83 | 84 | # Delegates 85 | 86 | ## Demo 87 | 88 | --- 89 | 90 | # Lambda Expressions 91 | 92 | ![bg right:50%](images/lambda.png) 93 | 94 | --- 95 | 96 | 97 | 98 | # Lambda Expressions 99 | 100 | ```csharp 101 | Action write = s => Console.WriteLine(s); 102 | 103 | Func square = a => a * a; 104 | ``` 105 | 106 | ```csharp 107 | Predicate b = c => c.Name.StartsWith("B"); 108 | 109 | Converter ftoC = c => c * 9.0 / 5.0 + 32.0; 110 | 111 | ... 112 | ``` 113 | 114 | --- 115 | 116 | 117 | 118 | # Local Functions 119 | 120 | ```csharp 121 | static void Main(string[] args) 122 | { 123 |     int square(int a) { return a * a; }; 124 | 125 |     Console.WriteLine(square(16)); 126 | } 127 | ``` 128 | 129 | --- 130 | 131 | # Local Functions 132 | 133 | ## Demo 134 | 135 | --- 136 | 137 | ![bg](images/belt.png) 138 | 139 | # Prerequisites 140 | 141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 | 154 | --- 155 | 156 | 157 | 158 | # Anonymous types 159 | 160 | ```csharp 161 | var question = new 162 | { 163 |     Title = "The answer...?", 164 |     Answer = 42 165 | }; 166 | ``` 167 | 168 | --- 169 | 170 | 171 | 172 | # (Tuples) 173 | 174 | ```csharp 175 | var s = Tuple.Create("Clark Kent", "Superman"); 176 | 177 | var b = ("Bruce Wayne", "Batman"); 178 | 179 | var f = (name: "Barry Allen", alterEgo: "The Flash"); 180 | 181 | var random = new Random(); 182 | 183 | IEnumerable<(float x, float y)> GenerateCoordinates() 184 | { 185 |     yield return (random.NextSingle() * 100, random.NextSingle() * 100); 186 | } 187 | ``` 188 | 189 | --- 190 | 191 | 192 | 193 | # Records 194 | 195 | ```csharp 196 | public record Superhero(string Name, string AlterEgo, DateTime FirstAppearance); 197 | ``` 198 | 199 | --- 200 | 201 | 202 | 203 | # Data: Collection Initializer 204 | 205 | ```csharp 206 | IEnumerable cities = new[] 207 | { 208 | new City(1, "Berlin"), 209 |     new City(2, "Hamburg"), 210 |     new City(3, "Frankfurt") 211 | }; 212 | ``` 213 | 214 | --- 215 | 216 | 217 | 218 | # Data: Collection + Object Initializer 219 | 220 | ```csharp 221 | IEnumerable cities = new[] 222 | { 223 |     new City { Id = 1, Name = "Berlin" }, 224 |     new City { Id = 2, Name = "Hamburg" }, 225 |     new City { Id = 3, Name = "Frankfurt" } 226 | }; 227 | ``` 228 | 229 | --- 230 | 231 | 232 | 233 | ![bg](images/extensions.jpg) 234 | 235 | # Extension Methods 236 | 237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 | 250 | --- 251 | 252 | 253 | 254 | # Built-in Extension methods 255 | 256 | ```csharp 257 | var count = cities.Count(); 258 | 259 | var sort = cities.OrderBy(c => c.Name); 260 | 261 | var filter = cities.Where(c => c.Name.Contains("i")); 262 | 263 | var pick = cities.FirstOrDefault(c => c.Id == 2); 264 | 265 | var all = cities.All(c => c.Name.Length < 10); 266 | 267 | var any = cities.Any(c => c.Name.StartsWith("B")); 268 | 269 | var project = cities.Select(c => c.Name); 270 | ``` 271 | 272 | --- 273 | 274 | 275 | 276 | # Create your own extension method 277 | 278 | ```csharp 279 | public static class Extensions 280 | { 281 | public static int WordCount(this string str) => 282 | str.Split(new[] { ' ', '.', '?' }, 283 | StringSplitOptions.RemoveEmptyEntries) 284 | .Length; 285 | } 286 | ``` 287 | 288 | --- 289 | 290 | # Extension methods 291 | 292 | ## Demo 293 | 294 | --- 295 | 296 | ![bg](images/questions.jpg) 297 | 298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 | 311 | # LINQ - Language INtegrated Query 312 | 313 | --- 314 | 315 | 316 | 317 | # LINQ 318 | 319 | 320 | 321 | ```csharp 322 | var sorted = from c in cities 323 |              where c.Name.Contains("i") 324 |              orderby c.Name descending 325 |              select new { Name = c.Name }; 326 | ``` 327 | 328 | ## Extension Methods Version 329 | 330 | ```csharp 331 | var sorted = cities.Where(c => c.Name.Contains("i")) 332 |                    .OrderByDescending(c => c.Name) 333 |                    .Select(c => new { Name = c.Name }); 334 | ``` 335 | 336 | --- 337 | 338 | # LINQ 339 | 340 | ## Demo 341 | 342 | --- 343 | 344 | ![bg](images/thank-you.jpg) 345 | 346 | # Thank you 347 | -------------------------------------------------------------------------------- /sessions/csharp_04/images/agenda.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_04/images/agenda.jpg -------------------------------------------------------------------------------- /sessions/csharp_04/images/applause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_04/images/applause.png -------------------------------------------------------------------------------- /sessions/csharp_04/images/azure-sql.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_04/images/azure-sql.png -------------------------------------------------------------------------------- /sessions/csharp_04/images/clean-architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_04/images/clean-architecture.png -------------------------------------------------------------------------------- /sessions/csharp_04/images/connection-meme.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_04/images/connection-meme.jpg -------------------------------------------------------------------------------- /sessions/csharp_04/images/database-popularity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_04/images/database-popularity.png -------------------------------------------------------------------------------- /sessions/csharp_04/images/databases.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_04/images/databases.png -------------------------------------------------------------------------------- /sessions/csharp_04/images/disposable.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_04/images/disposable.jpg -------------------------------------------------------------------------------- /sessions/csharp_04/images/entity-framework-core.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_04/images/entity-framework-core.jpg -------------------------------------------------------------------------------- /sessions/csharp_04/images/injection.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_04/images/injection.jpg -------------------------------------------------------------------------------- /sessions/csharp_04/images/lock.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_04/images/lock.jpg -------------------------------------------------------------------------------- /sessions/csharp_04/images/model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_04/images/model.png -------------------------------------------------------------------------------- /sessions/csharp_04/images/onion.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_04/images/onion.jpg -------------------------------------------------------------------------------- /sessions/csharp_04/images/orm.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_04/images/orm.jpg -------------------------------------------------------------------------------- /sessions/csharp_04/images/package.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_04/images/package.jpg -------------------------------------------------------------------------------- /sessions/csharp_04/images/pyramids.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_04/images/pyramids.jpg -------------------------------------------------------------------------------- /sessions/csharp_04/images/skyscrapers.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_04/images/skyscrapers.jpg -------------------------------------------------------------------------------- /sessions/csharp_04/slides.md: -------------------------------------------------------------------------------- 1 | --- 2 | marp: true 3 | author: Rasmus Lystrøm 4 | theme: default 5 | class: invert 6 | --- 7 | 8 | # C♯ 4 - Data Access and Entity Framework Core 9 | 10 | ![bg right:50%](images/azure-sql.png) 11 | 12 | Rasmus Lystrøm 13 | Associate Professor 14 | ITU 15 | 16 | --- 17 | 18 | # Assignment feedback 19 | 20 | ## Conformance to requirements! 21 | 22 | > To submit the assignment you need to create a PDF document using LaTeX that contains the answers to the questions **and** a link to a public GitHub repository that contains a fork of the assignments repository with the completed code. 23 | 24 | > The PDF file must conform to the following **naming convention: `group_____assignment_01.pdf`**, where `` is replaced by the number of your group from [README_GROUPS.md](./README_GROUPS.md) and ``, ``, and `` are your respective ITU identifiers. 25 | 26 | > You submit via [LearnIT](https://learnit.itu.dk/mod/assign/view.php?id=164354). 27 | 28 | > 29 | 30 | --- 31 | 32 | # Pop quiz! 33 | 34 | # Which of the following PDF files conforms to the file name requirement above? 35 | 36 | 1. `Assignment1.pdf` 37 | 1. `Group_1_aaaa_bbbb_cccc_assignment_01.pdf` 38 | 1. `group_1_aaaa_bbbb_cccc.pdf` 39 | 1. `Assignment_01-2.pdf` 40 | 1. `group_1_aaaa_bbbb_cccc_assignment_01.pdf` 41 | 42 | --- 43 | 44 | # Pop Quiz! 45 | 46 | # Which of the following PDF files conforms to the file name requirement above? 47 | 48 | 1. ✗ `Assignment1.pdf` 49 | 1. ✗ `Group_1_aaaa_bbbb_cccc_assignment_01.pdf` 50 | 1. ✗ `group_1_aaaa_bbbb_cccc.pdf` 51 | 1. ✗ `Assignment_01-2.pdf` 52 | 1. ✓ `group_1_aaaa_bbbb_cccc_assignment_01.pdf` 53 | 54 | --- 55 | 56 | # Pop Quiz! 57 | 58 | ## Which of the following actions satisfies the requirement above? 59 | 60 | - Handing in a link to a repository only 61 | - Handing in a PDF file only 62 | - Handing in a link to a repository and a PDF file 63 | 64 | --- 65 | 66 | # Pop Quiz! 67 | 68 | ## Which of the following actions satisfies the requirement above? 69 | 70 | - ✗ Handing in a link to a repository only 71 | - ✗ Handing in a PDF file only 72 | - ✓ Handing in a link to a repository and a PDF file 73 | 74 | --- 75 | 76 | # Topics 77 | 78 | 79 | 80 | ![bg blur:5px](images/agenda.jpg) 81 | 82 | Databases 83 | Old school SQL in C♯ 84 | Package managers and dependencies 85 | Secrets 86 | The IDisposable interface 87 | SQL Injection 88 | Object Relational Mapping 89 | Entity Framework Core 90 | Clean Onions 91 | Lazy vs. Eager Loading 92 | 93 | --- 94 | 95 | ![bg](images/databases.png) 96 | 97 | # Databases 98 | 99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 | 112 | --- 113 | 114 | # Relational Databases (SQL) 115 | 116 | Microsoft SQL Server 117 | Oracle Database 118 | IBM Db2 119 | MySQL 120 | MariaDB 121 | PostgreSQL 122 | SQLite 123 | 124 | ![bg left](images/pyramids.jpg) 125 | 126 | --- 127 | 128 | ## Document (NoSQL) 129 | 130 | Azure Cosmos DB 131 | Amazon DynamoDB 132 | MongoDB 133 | Couchbase 134 | Redis 135 | Elasticsearch 136 | Neo4j 137 | 138 | ![bg right](images/skyscrapers.jpg) 139 | 140 | --- 141 | 142 | # Most popular databases 143 | 144 | Source: 145 | 146 | ![bg right](images/database-popularity.png) 147 | 148 | --- 149 | 150 | 151 | 152 | # SQL Server 153 | 154 | ```bash 155 | sudo docker pull mcr.microsoft.com/mssql/server:2019-latest 156 | 157 | MSSQL_SA_PASSWORD= 158 | 159 | docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=$MSSQL_SA_PASSWORD" -p 1433:1433 -d mcr.microsoft.com/mssql/server:2019-latest 160 | ``` 161 | 162 | 163 | 164 | --- 165 | 166 | # SQL Server Demo 167 | 168 | ## SQL Server Docker Container + Azure Data Studio 169 | 170 | --- 171 | 172 | ![bg left:65%](images/connection-meme.jpg) 173 | 174 | 175 | 176 | --- 177 | 178 | ![bg](images/disposable.jpg) 179 | 180 | # IDisposable 181 | 182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 | 193 | --- 194 | 195 | 196 | 197 | # IDisposable 198 | 199 | ```csharp 200 | var connection = new SqlConnection("..."); 201 | try 202 | { 203 | ... 204 | } 205 | finally 206 | { 207 | if (connection != null) 208 |     { 209 |      connection.Dispose(); 210 | } 211 | } 212 | ``` 213 | 214 | --- 215 | 216 | ![bg](images/package.jpg) 217 | 218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 | 232 | # Package Manager 233 | 234 | --- 235 | 236 | # NuGet Package Manager 237 | 238 | Source: 239 | 240 | `dotnet add package …` 241 | 242 | Criteria: 243 | 244 | - Downloads 245 | - License 246 | - Dependencies 247 | - Update frequency 248 | - Check source repository 249 | 250 | --- 251 | 252 | ![bg right contain](https://avatars.githubusercontent.com/u/27347476?s=200&v=4) 253 | 254 | # Dependabot 255 | 256 | ## Demo 257 | 258 | --- 259 | 260 | # Old School SQL 261 | 262 | ```bash 263 | dotnet add package System.Data.SqlClient 264 | ``` 265 | 266 | ```csharp 267 | var cmdText = "SELECT * FROM Animals"; 268 | using var connection = new SqlConnection(connectionString); 269 | connection.Open(); 270 | using var command = new SqlCommand(cmdText, connection); 271 | using var reader = command.ExecuteReader(); 272 | while (reader.Read()) 273 | { 274 |     ... 275 | } 276 | ``` 277 | 278 | --- 279 | 280 | 281 | 282 | # IDisposable (Much better) 283 | 284 | ```csharp 285 | { 286 | using var connection = new SqlConnection("..."); 287 | 288 | ... 289 | } 290 | ``` 291 | 292 | --- 293 | 294 | ![bg right:60%](images/lock.jpg) 295 | 296 | # Secrets 297 | 298 | --- 299 | 300 | 301 | 302 | # Secrets 303 | 304 | ```bash 305 | dotnet user-secrets init 306 | dotnet user-secrets set "ConnectionStrings:ConnectionString" "..." 307 | dotnet add package Microsoft.Extensions.Configuration.UserSecrets 308 | ``` 309 | 310 | ```csharp 311 | using Microsoft.Extensions.Configuration; 312 | 313 | var configuration = new ConfigurationBuilder() 314 | .AddUserSecrets() 315 |     .Build(); 316 | var connectionString = configuration.GetConnectionString("ConnectionString"); 317 | ``` 318 | 319 | --- 320 | 321 | ![bg](images/injection.jpg) 322 | 323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 | 336 | # SQL Injection 337 | 338 | --- 339 | 340 | # SQL Injection 341 | 342 | A SQL injection attack consists of insertion or "injection" of a SQL query via the input data from the client to the application. 343 | 344 | A successful SQL injection exploit can: 345 | 346 | - read sensitive data from the database, 347 | - modify database data (Insert/Update/Delete), 348 | - execute administration operations on the database (such as shutdown the DBMS), 349 | or worse 350 | 351 | Source: 352 | 353 | --- 354 | 355 | 356 | 357 | ![bg 100%](images/orm.jpg) 358 | 359 | --- 360 | 361 | # Object Relational Mapping 362 | 363 | The act of converting incompatible types in OOP to tables/columns/rows/relations in SQL 364 | 365 | Object–relational impedance mismatch 366 | 367 | > Me not understand object me table 368 | 369 | --- 370 | 371 | 372 | 373 | ![bg 80%](images/model.png) 374 | 375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 | 389 | # Model 390 | 391 | --- 392 | 393 | ![bg](images/entity-framework-core.jpg) 394 | 395 | # Entity Framework Core 396 | 397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 | 410 | --- 411 | 412 | 413 | 414 | # Entity Framework Core 415 | 416 | ```bash 417 | dotnet tool install --global dotnet-ef 418 | dotnet add package Microsoft.EntityFrameworkCore.Design 419 | dotnet ef migrations add InitialCreate  420 | dotnet ef database update 421 | ``` 422 | 423 | 424 | 425 | 426 | --- 427 | 428 | ![bg](images/onion.jpg) 429 | 430 |
431 | 432 | # Onion Architecture 433 | 434 |
435 | 436 | --- 437 | 438 | 439 | 440 | ![bg 75%](images/clean-architecture.png) 441 | 442 | --- 443 | 444 | # Lazy Loading 445 | 446 | ```bash 447 | dotnet add package Microsoft.EntityFrameworkCore.Proxies 448 | ``` 449 | 450 | ```csharp 451 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 452 |     => optionsBuilder.UseLazyLoadingProxies() 453 |             .UseSqlServer(...); 454 | ``` 455 | 456 | 457 | 458 | --- 459 | 460 | ![bg right:60% contain](images/applause.png) 461 | 462 | # Thank you 463 | -------------------------------------------------------------------------------- /sessions/csharp_05/images/applause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_05/images/applause.png -------------------------------------------------------------------------------- /sessions/csharp_05/slides.md: -------------------------------------------------------------------------------- 1 | --- 2 | marp: true 3 | author: Rasmus Lystrøm 4 | theme: default 5 | class: invert 6 | --- 7 | 8 | # C♯ 05: Dependency Injection and Testing Entity Framework Core 9 | 10 | ![bg right:60%](https://samueleresca.net/content/images/wordpress/2017/02/How-To-Use-Dependency-Injection-in-ASP.NET-MVC-6.jpg) 11 | 12 | Rasmus Lystrøm 13 | Associate Professor 14 | ITU 15 | 16 | --- 17 | 18 | # Assignment feedback 19 | 20 | - How was it? 21 | - Testing? 22 | 23 | --- 24 | 25 | ![bg](https://miro.medium.com/max/1400/1*wgpae8kWxzQPG0XBAzUWYw.jpeg) 26 | 27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | 42 | # Repository pattern 43 | 44 | --- 45 | 46 | # Repository Pattern 47 | 48 | - Enable CRUD on domain objects (entities) 49 | 50 | - Usually: one repository per entity 51 | 52 | - Debatable: has a `Save()` method 53 | 54 | --- 55 | 56 | # Generic repository 57 | 58 | ```csharp 59 | public interface Repository 60 | { 61 |     T Create(T entity); 62 |     IReadOnlyCollection Read(); 63 |     T Read(K id); 64 |     void Update(T entity); 65 |     void Delete(K id); 66 | } 67 | ``` 68 | 69 | --- 70 | 71 | # Repository Pattern 72 | 73 | > ... but wait ...Entity Framework already does that for me!? 74 | 75 | --- 76 | 77 | # Recommended Repository: Per entity e.g., `Character` 78 | 79 | ```csharp 80 | public interface ICharacterRepository 81 | { 82 |     int Create(CharacterCreateDTO character); 83 |     CharacterDetailsDTO Read(int characterId); 84 |     IReadOnlyCollection Read(); 85 |     void Update(CharacterUpdateDTO character); 86 |     void Delete(int characterId); 87 | } 88 | ``` 89 | 90 | ...or something similar... 91 | 92 | --- 93 | 94 | # Testing... 95 | 96 | - Testing live databases is hard 97 | - Testing live full systems is hard 98 | - By transitivity: Testing ... is hard... 99 | 100 | --- 101 | 102 | 103 | 104 | ![bg contain](https://samueleresca.net/content/images/wordpress/2017/02/How-To-Use-Dependency-Injection-in-ASP.NET-MVC-6.jpg) 105 | 106 | --- 107 | 108 | # Dependency Injection 109 | 110 | Software design pattern which implements Inversion of Control (IoC) 111 | 112 | - Constructor Injection 113 | - Property (Setter) Injection 114 | - Interface Injection 115 | 116 | --- 117 | 118 | # Dependency Injection 119 | 120 | - Structured readable code 121 | - Testable code 122 | - Dependency Inversion Principle 123 | - Separation of Concerns 124 | - Rock SOLI***D***!!! <-- Pun intented 125 | - AWESOME!! 126 | 127 | --- 128 | 129 | # Programming to interface, not implementation… 130 | 131 | ```csharp 132 | public interface IFooService 133 | { 134 |     bool Bar(Foo foo); 135 | } 136 | 137 | public class FooService : IFooService 138 | { 139 |     bool Bar(Foo foo) 140 |     { 141 |          // Implementation 142 |     } 143 | } 144 | 145 | public interface IFooMapper 146 | { 147 |     Foo Map(Qux qux); 148 | } 149 | ``` 150 | 151 | --- 152 | 153 | ![bg right](https://cdn.shopify.com/s/files/1/1155/3572/articles/Untitled_design_71_1800x.png?v=1547597527) 154 | 155 | # Using IFooService? 156 | 157 | ```csharp 158 | public class Baz 159 | { 160 |     public bool Grault(Qux qux) 161 |     { 162 |         IFooMapper mapper = new FooMapper(); 163 |         var foo = mapper.Map(qux); 164 |         IFooService service = new FooService(); 165 |         return service.Bar(foo); 166 |     } 167 | } 168 | ``` 169 | 170 | --- 171 | 172 | # Constructor Injection (preferred) 173 | 174 | ```csharp 175 | public class Baz 176 | { 177 | private readonly IFooMapper _mapper; 178 | private readonly IFooService _service; 179 | 180 |     public Baz(IFooMapper mapper,  IFooService service) 181 |     { 182 |         _mapper = mapper; 183 |         _service = service; 184 |     } 185 | 186 |     public bool Grault(Qux qux) 187 |     { 188 |         var foo = _mapper.Map(qux); 189 |         return _service.Bar(foo); 190 |     } 191 | } 192 | ``` 193 | 194 | --- 195 | 196 | # Property Injection 197 | 198 | ```csharp 199 | public class Baz 200 | { 201 |     public IFooService Service { private get; set; } 202 | 203 |     public bool Grault(Qux qux) 204 |     { 205 | ... 206 | 207 |         return Service?.Update(foo); 208 |     } 209 | } 210 | ``` 211 | 212 | --- 213 | 214 | # Interface Injection 215 | 216 | ```csharp 217 | public interface IServiceSetter 218 | { 219 |     T Service { set; } 220 | } 221 | 222 | public class Baz : IServiceSetter 223 | { 224 |     public IFooService Service { private get; set; } 225 | 226 |     public bool Grault(Qux qux) 227 |     { 228 | ... 229 | 230 |         return Service?.Update(foo); 231 |     } 232 | } 233 | ``` 234 | 235 | --- 236 | 237 | # Best practices 238 | 239 | - Use Adapter to enable interface if needed 240 | - Use constructor injection 241 | - Program to interface 242 | - Use an IoC container (more on that later) 243 | - If you're injection more than 1-2-3 dependencies - you're doing it wrong! 244 | 245 | --- 246 | 247 | # Testing Entity Framework 248 | 249 | --- 250 | 251 | # SQLite in-memory database 252 | 253 | ```bash 254 | dotnet add package Microsoft.EntityFrameworkCore.Sqlite 255 | ``` 256 | 257 | ```csharp 258 | using var connection = new SqliteConnection("Filename=:memory:"); 259 | connection.Open(); 260 | var builder = new DbContextOptionsBuilder().UseSqlite(connection); 261 | using var context = new MyContext(builder.Options); 262 | ``` 263 | 264 | --- 265 | 266 | # Demo 267 | 268 | ## Testing Entity Framework with *SQLite in-memory* 269 | 270 | --- 271 | 272 | # Best practices 273 | 274 | - Wrap in logical units/service classes/repositories 275 | - Don’t test built-in code… 276 | - Program to interface 277 | - Repositories should not depend on other repositories 278 | - Use integration testing to ensure it all works 279 | 280 | --- 281 | 282 | # Integration testing 283 | 284 | - You must test against a real database eventually 285 | - More on this later in the course 286 | 287 | --- 288 | 289 | ![bg right:60% contain](images/applause.png) 290 | 291 | # Thank you 292 | -------------------------------------------------------------------------------- /sessions/csharp_06/images/concurrency.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_06/images/concurrency.jpg -------------------------------------------------------------------------------- /sessions/csharp_06/images/deadlock.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_06/images/deadlock.jpg -------------------------------------------------------------------------------- /sessions/csharp_06/images/funko_pop_collection_by_needxxx_dazxmlc-fullview.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_06/images/funko_pop_collection_by_needxxx_dazxmlc-fullview.jpg -------------------------------------------------------------------------------- /sessions/csharp_06/images/i-am-a-waiting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_06/images/i-am-a-waiting.png -------------------------------------------------------------------------------- /sessions/csharp_06/images/main-worker-thread.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_06/images/main-worker-thread.png -------------------------------------------------------------------------------- /sessions/csharp_06/images/nails.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_06/images/nails.jpg -------------------------------------------------------------------------------- /sessions/csharp_06/images/race-condition.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_06/images/race-condition.png -------------------------------------------------------------------------------- /sessions/csharp_06/images/stack-heap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_06/images/stack-heap.png -------------------------------------------------------------------------------- /sessions/csharp_06/images/thread.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_06/images/thread.jpg -------------------------------------------------------------------------------- /sessions/csharp_06/slides.md: -------------------------------------------------------------------------------- 1 | --- 2 | marp: true 3 | author: Rasmus Lystrøm 4 | theme: default 5 | class: invert 6 | --- 7 | 8 | # C♯ 06: Asynchronous and Parallel Programming 9 | 10 | ![bg right](https://upload.wikimedia.org/wikipedia/commons/5/55/Overhead_Communication_Cables_-_Kolkata_2011-08-29_4821.JPG) 11 | 12 | Rasmus Lystrøm 13 | Associate Professor 14 | ITU 15 | 16 | --- 17 | 18 | # The Gilded Rose 19 | 20 | Introduction 21 | 22 | --- 23 | 24 | ![bg](https://www.macmillandictionaryblog.com/wp-content/uploads/2018/01/dictionary-1024x575.jpg) 25 | 26 | # Dictionary 27 | 28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | 41 | --- 42 | 43 | # Async ≠ Parallel ≠ Threads 44 | 45 | --- 46 | 47 | ![bg](images/concurrency.jpg) 48 | 49 | # Concurrency 50 | 51 | --- 52 | 53 | # Concurrency I 54 | 55 | > A property of systems in which several computations are executing simultaneously, and potentially interacting with each other. The computations may be executing on multiple cores in the same chip, preemptively time-shared threads on the same processor, or executed on physically separated processors. 56 | 57 | --- 58 | 59 | # Concurrency II 60 | 61 | > Multiple tasks which start, run, and complete in overlapping time periods, in no specific order. 62 | 63 | --- 64 | 65 | ![bg](https://live.staticflickr.com/7517/15550717054_a3a85a6573_z.jpg) 66 | 67 | # Parallelism 68 | 69 | --- 70 | 71 | # Parallelism 72 | 73 | > When multiple tasks OR several parts of a unique task literally run at the same time, e.g., on a multi-core processor. 74 | 75 | --- 76 | 77 | 78 | 79 | ![bg](images/thread.jpg) 80 | 81 | # Multithreading 82 | 83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 | 94 | --- 95 | 96 | # Multithreading 97 | 98 | > Software implementation which allows different threads to be executed concurrently. 99 | > A multithreaded program appears to be doing several things at the same time even when it's running on a single-core machine. 100 | > Compare to chatting with different people through various IM windows; although you're switching back and forth, the net result is that you're having multiple conversations at the same time. 101 | 102 | --- 103 | 104 | 105 | 106 | ![bg](https://www.duperrin.com/english/wp-content/uploads/2020/06/desynchronized-organization.jpg) 107 | 108 | # Asynchronous methods 109 | 110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 | 123 | --- 124 | 125 | # Asynchronous methods 126 | 127 | > Asynchrony is used to present the impression of concurrent or parallel tasking. 128 | > Normally used for a process that needs to do work away from the current application where we don't want to wait and block our application awaiting the response. 129 | 130 | --- 131 | 132 | 133 | 134 | ![bg](images/nails.jpg) 135 | 136 | # Threads 137 | 138 | --- 139 | 140 | 141 | 142 | ![bg contain](images/stack-heap.png) 143 | 144 | --- 145 | 146 | 147 | 148 | ![bg width:90%](images/main-worker-thread.png) 149 | 150 | # Threads Example 151 | 152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 | 165 | --- 166 | 167 | ![bg](images/race-condition.png "Ralf Schumacher, 3 Mar 2002, Reporter Images") 168 | 169 | # Race Condition 170 | 171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 | 184 | --- 185 | 186 | # Race Condition 187 | 188 | > Behavior of a program where the output is dependent on the sequence or timing of other uncontrollable events. 189 | --> Bug, when events do not happen in the order the programmer intended. 190 | 191 | --- 192 | 193 | 194 | 195 | ![bg width:250%](images/race-condition.png) 196 | 197 | # Race Condition 198 | 199 | ## Demo 200 | 201 | --- 202 | 203 | ![bg](images/deadlock.jpg "Deadlock by David Mailtland") 204 | 205 | # Deadlock 206 | 207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 | 220 | --- 221 | 222 | # Deadlock 223 | 224 | > A situation in which two or more competing actions are each waiting for the other to finish, and thus neither ever does. 225 | 226 | --- 227 | 228 | ![bg right](https://i.stack.imgur.com/kKSUL.gif) 229 | 230 | # Deadlock 231 | 232 | ## Demo 233 | 234 | --- 235 | 236 | 237 | 238 | ![bg](https://upload.wikimedia.org/wikipedia/commons/2/21/RyersonUniversityLibrary.JPG) 239 | 240 | # Task Parallel Library 241 | 242 | ## Demo 243 | 244 | --- 245 | 246 | # TPL 247 | 248 | Task.Run 249 | Task.Factory… 250 | Task.Delay 251 | Parallel.For 252 | Parallel.ForEach 253 | Parallel.Invoke 254 | 255 | Parallel Linq --> .AsParallel() 256 | 257 | --- 258 | 259 | ![bg](images/funko_pop_collection_by_needxxx_dazxmlc-fullview.jpg) 260 | 261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 | 274 | # Concurrent Collections 275 | 276 | --- 277 | 278 | # `System.Collections.Concurrent` 279 | 280 | `ConcurrentQueue` 281 | `ConcurrentStack` 282 | `BlockingCollection` 283 | `ConcurrentDictionary` 284 | 285 | --- 286 | 287 | 288 | 289 | ![bg](images/i-am-a-waiting.png) 290 | 291 | # Asynchronous Programming 292 | 293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 | 307 | --- 308 | 309 | # Asynchronous Programming 310 | 311 | > **Asynchronous programming** is a means of **parallel programming** in which a unit of work runs separately from the main application thread and notifies the calling thread of its completion, failure or progress. 312 | 313 | --- 314 | 315 | # Asynchronous Programming 316 | 317 | ## Demo 318 | 319 | --- 320 | 321 | # `async` / `await` 322 | 323 | `async` --> 324 | 325 | Method must return `void`, `Task`, `Task`, `ValueTask`, `ValueTask`, or a task-like type. 326 | 327 | Specifically: a type, which satisfy the *async* pattern, meaning a `GetAwaiter` method must be accessible. 328 | 329 | `await` --> Await task(s)... 330 | 331 | Note: Asynchronous `Main` and *test* methods must return `Task` 332 | 333 | --- 334 | 335 | # Async ≠ Parallel ≠ Threads 336 | 337 | *Async*: Non-blocking UI, background tasks, asynchronous 338 | 339 | *Parallel*: Speed, Multiprocessor, Parallel execution 340 | 341 | *Thread*: Low-level building block. Do not use directly! 342 | 343 | --- 344 | 345 | # Thank you 346 | -------------------------------------------------------------------------------- /sessions/csharp_07/images/418.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_07/images/418.png -------------------------------------------------------------------------------- /sessions/csharp_07/images/mvc-api.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_07/images/mvc-api.png -------------------------------------------------------------------------------- /sessions/csharp_07/images/mvc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_07/images/mvc.png -------------------------------------------------------------------------------- /sessions/csharp_07/slides.md: -------------------------------------------------------------------------------- 1 | --- 2 | marp: true 3 | author: Rasmus Lystrøm 4 | theme: default 5 | class: invert 6 | --- 7 | 8 | # C♯ 07: JSON and the REST 9 | 10 | ![bg right](https://live.staticflickr.com/220/468513562_75b94fc44c_o.jpg) 11 | 12 | Rasmus Lystrøm 13 | Associate Professor 14 | ITU 15 | 16 | --- 17 | 18 | # The Project 19 | 20 | More info on Monday 21 | 22 | --- 23 | 24 | # The Gilded Rose 25 | 26 | Recap 27 | 28 | --- 29 | 30 | # Parallel LINQ 31 | 32 | Carry-over from last week 33 | 34 | --- 35 | 36 | # XML 37 | 38 | eXtensible Markup Language 39 | Markup language like HTML 40 | Designed to carry data, not to display data 41 | Tags are not predefined – You must define your own tags 42 | Designed to be self-descriptive 43 | 44 | --- 45 | 46 | 47 | 48 | # XML does not do anything 49 | 50 | XML was created to structure, store, and transport information 51 | 52 | ```xml 53 |   54 | 55 |   Kathleen B. 56 |   Tom W. 57 |   Reminder 58 |   Don't forget to bring small change! 59 | 60 | ``` 61 | 62 | --- 63 | 64 | # How Can XML be Used? 65 | 66 | Separates data from HTML 67 | Simplifies data sharing 68 | Simplifies data transport 69 | Simplifies platform changes 70 | Used to create new (Internet) languages 71 | 72 | - XHTML 73 | - WSDL for describing web services 74 | - RSS and ATOM for news feeds 75 | - XAML 76 | 77 | --- 78 | 79 | 80 | 81 | ![bg contain](https://pngimg.com/uploads/soap/soap_PNG51.png) 82 | 83 | --- 84 | 85 | 86 | 87 | # SOAP request 88 | 89 | ```http 90 | POST https://store.com/services/PriceService/getPrice 91 | ``` 92 | 93 | ```xml 94 | 95 | 98 |    99 | 100 | Apples    101 | 102 | 103 | 104 | ``` 105 | 106 | --- 107 | 108 | 109 | 110 | # SOAP response 111 | 112 | ```xml 113 | 114 |    117 | 118 | 1.90    119 | 120 | 121 | 122 | ``` 123 | 124 | --- 125 | 126 | ![bg](https://upload.wikimedia.org/wikipedia/commons/1/11/JasonVoorheesMask.jpg) 127 | 128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 | 141 | # JSON 142 | 143 | --- 144 | 145 | # JSON 146 | 147 | JavaScript Object Notation 148 | Lightweight text-data interchange format 149 | Language independent (uses JavaScript syntax) 150 | "Self-describing" and easy to understand 151 | 152 | --- 153 | 154 | # JSON Syntax 155 | 156 | (subset of the JavaScript object notation syntax) 157 | 158 | Data is in name/value pairs 159 | Data is separated by commas 160 | Curly braces hold objects 161 | Square brackets hold arrays 162 | 163 | --- 164 | 165 | # JSON Name/Value Pairs 166 | 167 | A name/value pair consists of a field name (in double quotes), followed by a colon, followed by a value: 168 | 169 | ```json 170 | "givenName": "John" 171 | ``` 172 | 173 | This is simple to understand, and equals to the JavaScript statement: 174 | 175 | ```javascript 176 | givenName = "John" 177 | ``` 178 | 179 | --- 180 | 181 | JSON Data Types 182 | 183 | Number: `42` or `2.71828182845905` 184 | String: `"this is a string"` 185 | Boolean: `true` or `false` 186 | Array: `[]` 187 | Object: `{}` 188 | Null: `null` 189 | 190 | --- 191 | 192 | 193 | 194 | # Examples 195 | 196 | ```json 197 | { "alterEgo": "Batman", "firstAppearance": 1939 } 198 | ``` 199 | 200 | ```json 201 | [ 202 |   { "givenName": "Bruce", "surname": "Wayne" }, 203 |   { "givenName": "Bruce", "surname": "Lee" }, 204 |   { "givenName": "Bruce", "surname": "Dickinson" } 205 |   { "givenName": "Bruce", "surname": "Campbell" } 206 |   { "givenName": "Robert", "surname": "the Bruce" } 207 | ] 208 | ``` 209 | 210 | ```json 211 | null 212 | ``` 213 | 214 | ```json 215 | "Batman" 216 | ``` 217 | 218 | --- 219 | 220 | # Best of both worlds? 221 | 222 | 223 | 224 | --- 225 | 226 | ![bg](https://atareao.es/wp-content/uploads/2020/06/yaml-1024x683.jpg) 227 | 228 | # YAML 229 | 230 | --- 231 | 232 | # YAML 233 | 234 | YAML Ain't Markup Language 235 | 236 | Human-readable data-serialization language. 237 | 238 | It is commonly used for configuration files and in applications where data is being stored or transmitted. 239 | 240 | Superset of JSON 241 | 242 | --- 243 | 244 | 245 | 246 | # YAML Example 247 | 248 | ```yaml 249 | version: '3.9' 250 | services: 251 |   sql-server: 252 |     image: mcr.microsoft.com/mssql/server:2019-latest 253 |     hostname: sql-server 254 |     container_name: sql-server 255 |     ports: 256 |       - 1433:1433 257 |     environment: 258 |       ACCEPT_EULA: 'Y' 259 |       MSSQL_SA_PASSWORD_FILE: /run/secrets/sa_password 260 |       MSSQL_PID: Express 261 | secrets: 262 |   sa_password: 263 |     file: ./local/sa_password.txt 264 | ``` 265 | 266 | --- 267 | 268 | # REST 269 | 270 | # REpresentational State Transfer 271 | 272 | --- 273 | 274 | # HTTP request 275 | 276 | **URI**: string 277 | **(Query)**: key/value pairs 278 | **Method**: string 279 | **Header**: key/value pairs 280 | **Body**: string/binary 281 | 282 | --- 283 | 284 | # HTTP response 285 | 286 | **Status-Code**: number 287 | **Header**: key/value pairs 288 | **Body**: string/binary 289 | 290 | --- 291 | 292 | # REST 293 | 294 | Maps your CRUD actions to HTTP verbs: 295 | 296 | |Action|Verb| 297 | |:----|:----| 298 | |Create|POST| 299 | |Read (Retrieve)|GET| 300 | |Update (Replace)|PUT| 301 | |Update (Modify)|PATCH| 302 | |Delete|DELETE| 303 | 304 | --- 305 | 306 | # HTTP status codes 307 | 308 | |Code|Meaning| 309 | |:----|:----| 310 | |200|OK| 311 | |201|Created| 312 | |202|Accepted| 313 | |204|No Content| 314 | |301|Moved Permanently| 315 | |302|Found (Previously "Moved temporarily")| 316 | |307|Temporary Redirect| 317 | |308|Permanent Redirect| 318 | |400|Bad Request| 319 | |401|Unauthorized| 320 | |403|Forbidden| 321 | |404|Not Found| 322 | |409|Conflict| 323 | |415|Unsupported Media Type418|I’m a Teapot| 324 | |422|Unprocessable Entity| 325 | |500|Internal Server Error| 326 | |501|Not Implemented| 327 | |503|Service Unavailable| 328 | 329 | --- 330 | 331 | 332 | 333 | # RFC2324: Hyper Text Coffee Pot Control Protocol 334 | 335 | ![width:900](images/418.png) 336 | 337 | Source: 338 | 339 | --- 340 | 341 | # HTTP headers 342 | 343 | |Header Field|Description|Examples| 344 | |:----|:----|:----| 345 | |Accept|I understand|`text/plain`
`application/json`
`application/xml`| 346 | |Content-Type|I'm sending|`application/x-www-form-urlencoded`
`application/json; charset=utf-8`| 347 | |Authorization|Who I am|`Bearer ey…`| 348 | 349 | --- 350 | 351 | # Why REST? 352 | 353 | Simple, both conceptually and programmatically 354 | 355 | Simpler and cleaner than SOAP 356 | 357 | REST is the new black 358 | 359 | --- 360 | 361 | # REST request 362 | 363 | ```http 364 | GET https://store.com/prices/Apples 365 | ``` 366 | 367 | --- 368 | 369 | # REST response 370 | 371 | ```json 372 | 1.9 373 | ``` 374 | 375 | --- 376 | 377 | # HTTP request 378 | 379 | **URI**: 380 | **Method**: `POST` 381 | **Header**: 382 | `Content-Type`: `application/json; charset=utf-8` 383 | `Authorization`: `Bearer ey...` 384 | **Body**: 385 | 386 | ```json 387 | { 388 | "name": "Bender", 389 | "species": "Robot", 390 | "planet": "Earth" 391 | } 392 | ``` 393 | 394 | --- 395 | 396 | # HTTP response 397 | 398 | **Status-Code**: `201` 399 | **Header**: 400 | `Content-Type`: `application/json; charset=utf-8` 401 | `Location`: `https://futurama.com/api/characters/42` 402 | **Body**: 403 | 404 | ```json 405 | { 406 | "id": 42, 407 | "name": "Bender", 408 | "species": "Robot", 409 | "planet": "Earth" 410 | } 411 | ``` 412 | 413 | --- 414 | 415 | # ASP.NET Core 416 | 417 | --- 418 | 419 | 420 | 421 | # Model – View – Controller 422 | 423 | ![width:900](images/mvc.png) 424 | 425 | --- 426 | 427 | 428 | 429 | # ASP.NET Core Web API 430 | 431 | ![width:900](images/mvc-api.png) 432 | 433 | --- 434 | 435 | # MVC elsewhere 436 | 437 | - [Spring Framework](https://spring.io/projects/spring-framework): 2002 (Java) 438 | - [Ruby on Rails](https://rubyonrails.org/): 2004 439 | - [CakePHP](https://cakephp.org/): 2005 440 | - [Catalyst](http://catalyst.perl.org/): 2005 (Perl) 441 | - [CodeIgniter](https://codeigniter.com/): 2006 (PHP) 442 | - ASP.NET MVC: 2009 443 | - ASP.NET Core: 2016 444 | 445 | --- 446 | 447 | # ASP.NET Core Web API 448 | 449 | ## Demo 450 | 451 | `dotnet new --list` 452 | 453 | --- 454 | 455 | # Controller 456 | 457 | ## Class 458 | 459 | Derive from `ControllerBase` 460 | Decorate with `[ApiController]` and `[Route("[controller]")]` 461 | 462 | ## Method 463 | 464 | Decorate with `[HttpGet]`,`[HttpPost]`, `[HttpPut]`, or `[HttpDelete]` 465 | Return specific type, `IActionResult`, `ActionResult`, or `async Task<...>`. 466 | 467 | --- 468 | 469 | # Thank You 470 | -------------------------------------------------------------------------------- /sessions/csharp_08/slides.md: -------------------------------------------------------------------------------- 1 | --- 2 | marp: true 3 | author: Rasmus Lystrøm 4 | theme: default 5 | class: invert 6 | --- 7 | 8 | # C♯ 08: JSON and the REST part deux 9 | 10 | ![bg right](https://i0.wp.com/farm1.staticflickr.com/207/476245464_2b59cc08f2_z.jpg) 11 | 12 | Rasmus Lystrøm 13 | Associate Professor 14 | ITU 15 | 16 | --- 17 | 18 | # Documenting ASP.NET Core 19 | 20 | ## Demo 21 | 22 | --- 23 | 24 | 25 | 26 | # Support the OpenAPI Specification (Swagger) 27 | 28 | ```bash 29 | dotnet add package Swashbuckle.AspNetCore 30 | ``` 31 | 32 | ```csharp 33 | builder.Services.AddSwaggerGen(); 34 | 35 | var app = builder.Build(); 36 | 37 | if (app.Environment.IsDevelopment()) 38 | { 39 | app.UseSwagger(); 40 | app.UseSwaggerUI(); 41 | } 42 | ``` 43 | 44 | --- 45 | 46 | 47 | 48 | # Support HTTPS only 49 | 50 | Cf. [Enforce HTTPS in ASP.NET Core](https://learn.microsoft.com/en-us/aspnet/core/security/enforcing-ssl) 51 | 52 | ```bash 53 | dotnet dev-certs https --trust 54 | ``` 55 | 56 | ```csharp 57 | app.UseHttpsRedirection(); 58 | ``` 59 | 60 | --- 61 | 62 | 63 | 64 | # Standardize on lowercase urls 65 | 66 | ```csharp 67 | builder.Services.AddRouting(options => options.LowercaseUrls = true); 68 | ``` 69 | 70 | --- 71 | 72 | # Secure your Web API 73 | 74 | Azure AD 75 | Azure AD B2C 76 | 3rd party 77 | 78 | **Do not write your own security layer!!!** 79 | 80 | --- 81 | 82 | ![bg](https://upload.wikimedia.org/wikipedia/commons/2/2a/CSIRO_ScienceImage_2819_Preparing_samples_of_soy_sauce_for_testing.jpg) 83 | 84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 | 97 | # Testing ASP.NET Core 98 | 99 | --- 100 | 101 | # Stub --> Mock --> Fake 102 | 103 | --- 104 | 105 | # Stubs 106 | 107 | ```csharp 108 | public class FooServiceFalseStub : IFooService 109 | { 110 |     public bool Bar(Foo foo) 111 |     { 112 |         return false; 113 |     } 114 | } 115 | ``` 116 | 117 | --- 118 | 119 | # Test using stub 120 | 121 | ```csharp 122 | 123 | [Fact] 124 | public void Exec_when_IFooService_Update_returns_false_returns_false() 125 | { 126 | IFooService service = new FooServiceTrueStub(); 127 | var baz = new Baz(service); 128 | var result = baz.Exec(new Foo()); 129 | result.Should().Be(false); 130 | } 131 | ``` 132 | 133 | --- 134 | 135 | # Faking it using Moq 136 | 137 | ```bash 138 | dotnet add package Moq 139 | ``` 140 | 141 | ```csharp 142 | [Fact] 143 | public void Exec_when_IFooService_Update_returns_false_returns_false() 144 | { 145 |     var mock = new Mock(); 146 |     IFooService service = mock.Object; 147 | var baz = new Baz(service); 148 |      149 |     var result = baz.Exec(new Foo()); 150 |     result.Should().Be(false); 151 | } 152 | ``` 153 | 154 | --- 155 | 156 | # Faking it using Moq (advanced) 157 | 158 | ```csharp 159 | [Fact] 160 | public void Exec_when_IFooService_Update_true_returns_true() 161 | { 162 |     var mock = new Mock(); 163 |     mock.Setup(m => m.Update(It.IsAny())).Returns(true); 164 |     var baz = new Baz(mock.Object); 165 |      166 |     var result = baz.Exec(new Foo()); 167 |     result.Should().Be(true); 168 | } 169 | ``` 170 | 171 | --- 172 | 173 | # Faking it using NSubstitute 174 | 175 | ```bash 176 | dotnet add package NSubstitute 177 | ``` 178 | 179 | ```csharp 180 | [Fact] 181 | public void Exec_when_IFooService_Update_returns_false_returns_false() 182 | { 183 |     var service = Substitute.For(); 184 | var baz = new Baz(service); 185 |      186 |     var result = baz.Exec(new Foo()); 187 |     result.Should().Be(false); 188 | } 189 | ``` 190 | 191 | --- 192 | 193 | # Faking it using NSubstitute (advanced) 194 | 195 | ```csharp 196 | [Fact] 197 | public void Exec_when_IFooService_Update_true_returns_true() 198 | { 199 |     var service = Substitute.For(); 200 |     service.Update(Arg.Any()).Returns(true); 201 |     var baz = new Baz(service); 202 |      203 |     var result = baz.Exec(new Foo()); 204 |     result.Should().Be(true); 205 | } 206 | ``` 207 | 208 | --- 209 | 210 | # Testing ASP.NET Core with fakes 211 | 212 | ## Demo 213 | 214 | --- 215 | 216 | # [ASP.NET Minimal APIs](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis) 217 | 218 | `dotnet new webapi -minimal` 219 | 220 | *Controllers are so yesterday...* 221 | 222 | ## Demo 223 | 224 | --- 225 | 226 | # [Integration tests in ASP.NET Core](https://learn.microsoft.com/en-us/aspnet/core/test/integration-tests?view=aspnetcore-6.0) 227 | 228 | ## Demo 229 | 230 | --- 231 | 232 | # gRPC 233 | 234 | > gRPC is a modern, open source, high-performance remote procedure call (RPC) framework that can run anywhere. gRPC enables client and server applications to communicate transparently, and simplifies the building of connected systems. 235 | 236 | Source: 237 | 238 | ```bash 239 | dotnet new grpc 240 | ``` 241 | 242 | --- 243 | 244 | # GraphQL 245 | 246 | > GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data. GraphQL provides a complete and understandable description of the data in your API, gives clients the power to ask for exactly what they need and nothing more, makes it easier to evolve APIs over time, and enables powerful developer tools. 247 | 248 | Source: 249 | 250 | --- 251 | 252 | # Thank You 253 | -------------------------------------------------------------------------------- /sessions/csharp_09/images/angular.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_09/images/angular.png -------------------------------------------------------------------------------- /sessions/csharp_09/images/react.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_09/images/react.png -------------------------------------------------------------------------------- /sessions/csharp_09/images/vue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_09/images/vue.png -------------------------------------------------------------------------------- /sessions/csharp_09/images/webapps.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_09/images/webapps.jpg -------------------------------------------------------------------------------- /sessions/csharp_09/slides.md: -------------------------------------------------------------------------------- 1 | --- 2 | marp: true 3 | author: Rasmus Lystrøm 4 | theme: default 5 | class: invert 6 | --- 7 | 8 | # C♯ 09: .NET Web Applications 9 | 10 | ![bg right](https://www.publicdomainpictures.net/pictures/40000/velka/webspin.jpg) 11 | 12 | Rasmus Lystrøm 13 | Associate Professor 14 | ITU 15 | 16 | --- 17 | 18 | ![bg right](https://www.dotnetconf.net/img/hero-illustration-bot.svg) 19 | 20 | # .NET Conf 2022 21 | 22 | November 8–10 23 | 24 | - .NET 7 25 | - ASP.NET Core 26 | - Blazor 27 | - Minimal APIs 28 | - .NET MAUI 29 | - C♯ 11 30 | 31 | 32 | 33 | --- 34 | 35 | # Server-side vs. client-side rendering 36 | 37 | TODO 38 | 39 | --- 40 | 41 | ![bg](images/webapps.jpg) 42 | 43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | 55 | # ASP.NET Web Applications 56 | 57 | --- 58 | 59 | # ASP.NET Web Applications 60 | 61 | ASP.NET Web Forms (2002) 62 | ASP.NET MVC (2010) --> Core 63 | ASP.NET Web Pages (2010) --> Core 64 | ASP.NET Core (2016) 65 | 66 | - Razor Pages 67 | - MVC 68 | - Blazor (Server or WebAssembly) (2018) 69 | - SPA (Angular or React) 70 | - Hybrid MVC + Blazor 71 | 72 | 73 | 74 | --- 75 | 76 | 77 | 78 | # ASP.NET Core Razor Pages 79 | 80 | Razor Pages can make coding page-focused scenarios easier and more productive than using controllers and views. 81 | 82 | ```bash 83 | dotnet new webapp 84 | ``` 85 | 86 | 87 | 88 | --- 89 | 90 | 91 | 92 | ![bg right contain](https://learn.microsoft.com/en-us/aspnet/core/mvc/overview/_static/mvc.png) 93 | 94 | # ASP.NET Core MVC 95 | 96 | ASP.NET Core MVC is a rich framework for building web apps and APIs using the Model-View-Controller design pattern. 97 | 98 | ```bash 99 | dotnet new mvc 100 | ``` 101 | 102 | 103 | 104 | --- 105 | 106 | 107 | 108 | # Blazor 109 | 110 | Blazor is a framework for building interactive client-side web UI with .NET: 111 | 112 | [Beginner's Series to: Blazor 113 | ](https://learn.microsoft.com/en-us/shows/beginners-series-to-blazor/) 114 | 115 | ```bash 116 | dotnet new blazorserver 117 | dotnet new blazorwasm 118 | ``` 119 | 120 | 121 | 122 | 123 | --- 124 | 125 | 126 | 127 | # Single Page Application (SPA) 128 | 129 | ![height:300px](images/angular.png) ![height:300px](images/react.png) ![height:300px](images/vue.png) 130 | 131 | ```bash 132 | dotnet new angular 133 | dotnet new react 134 | ``` 135 | 136 | --- 137 | 138 | # ASP.NET Web Applications 139 | 140 | ## Demo 141 | 142 | --- 143 | 144 | 145 | 146 | ![bg right contain](https://www.pmstudio.be/wp-content/uploads/2017/04/Re-invent-the-wheel.png) 147 | 148 | # Building your own components 149 | 150 | --- 151 | 152 | # Component Vendors 153 | 154 | Telerik: 155 | DevExpress: 156 | Radzen: 157 | 158 | --- 159 | 160 | # Components 161 | 162 | ## Demo 163 | 164 | --- 165 | 166 | # How to choose a framework 167 | 168 | --- 169 | 170 | # How to choose a framework 171 | 172 | 1. Install Studio Professional/VisualEnterprise/for Mac 173 | 1. TEST out all the templates one by one 174 | 1. Get your own feel for pros/cons of each framework for your scenario 175 | 1. **When your done; select Blazor!** 176 | 177 | --- 178 | 179 | # No, really 180 | 181 | - Pick the one where you believe you will be the most productive 182 | - Don’t be afraid to change your mind 183 | - Be prepared: The next great thing which is better than all the others will arrive tomorrow or next year approx. 184 | 185 | --- 186 | 187 | # Thank You 188 | -------------------------------------------------------------------------------- /sessions/csharp_10/images/ali-farahnak.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_10/images/ali-farahnak.jpg -------------------------------------------------------------------------------- /sessions/csharp_10/images/button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_10/images/button.png -------------------------------------------------------------------------------- /sessions/csharp_10/images/rip.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itu-bdsa/lecture-notes/896656a0910eb43dfd371cce9917dd8a25a4bf58/sessions/csharp_10/images/rip.gif -------------------------------------------------------------------------------- /sessions/csharp_10/slides.md: -------------------------------------------------------------------------------- 1 | --- 2 | marp: true 3 | author: Rasmus Lystrøm 4 | theme: default 5 | class: invert 6 | --- 7 | 8 | # C♯ 10: .NET Mobile and Desktop Applications 9 | 10 | ![bg right](https://upload.wikimedia.org/wikipedia/commons/f/f4/Ordi-portable-milouf-img_0999.jpg) 11 | 12 | Rasmus Lystrøm 13 | Associate Professor 14 | ITU 15 | 16 | --- 17 | 18 | # Info 19 | 20 | ## No lectures next week 21 | 22 | Use the extra time to catch up with your project and work on the new requirements 23 | 24 | --- 25 | 26 | 27 | 28 | ![height:300px](images/ali-farahnak.jpg) 29 | 30 | # Guest Lecture 31 | 32 | ## Mobile Application Development with C♯ 33 | 34 | Ali Reza Farahnak 35 | Senior Cloud Solution Architect - Engineering 36 | 37 | --- 38 | 39 | # Mobile and Desktop Applications in .NET 40 | 41 | Windows Forms (WinForms) (2002) 42 | 43 | Windows Presentation Foundation (WPF) (2006) 44 | 45 | Silverlight (2007-2019) 46 | 47 | Xamarin.Forms (2014) (acquired by Microsoft in 2016) 48 | 49 | Universal Windows Platform (UWP) (2015-2021?) 50 | 51 | Windows UI Library (WinUI) (2021) 52 | 53 | .NET Multi-platform App UI (MAUI) (2021) 54 | 55 | --- 56 | 57 | # XAML: eXtensible Application Markup Language 58 | 59 | Windows Desktop (WPF) 60 | .NET MAUI 61 | WinUI 62 | 63 | ![](images/rip.gif) 64 | 65 | Xamarin.Forms (iOS, Android, Windows) 66 | Silverlight (web) 67 | Universal Windows Platform (anything windowsy) 68 | 69 | --- 70 | 71 | # XAML 72 | 73 | Markup language for declaratively designing and creating application UIs 74 | 75 | XAML maps XML markup to objects in the .NET Framework 76 | 77 | Every tag maps to a class and every attribute to a property 78 | 79 | Markup and procedural code are peers in functionality and performance 80 | 81 | Code and markup are both first class citizens 82 | 83 | Consistent model between UI, documents, and media 84 | 85 | Compiled to code 86 | 87 | --- 88 | 89 | 90 | 91 | # XAML Markup vs. Code 92 | 93 | ```xml 94 | 99 | ``` 100 | 101 | ![height:100px](images/button.png) 102 | 103 | ```csharp 104 | var button = new Button(); 105 | button.Content = "OK"; 106 | button.Background = new SolidColorBrush(Colors.Purple); 107 | button.Width = 100; 108 | ``` 109 | 110 | --- 111 | 112 | 113 | 114 | # MainPage.xaml 115 | 116 | ```xml 117 | 118 | 119 | 120 | 122 |