Measuring Functional Purity In C# : Developing and implementing a technique for measuring functional purity in C#
Functional purity is a fundamental part of the functional programming paradigm. A function is functionally pure if it is side-effect free and deterministic. Pure functions provide many benefits compared to impure ones, including guaranteed thread-safety as well as easier testing, debugging and maint...
Main Author: | |
---|---|
Format: | Others |
Language: | English |
Published: |
Uppsala universitet, Institutionen för informationsteknologi
2021
|
Subjects: | |
Online Access: | http://urn.kb.se/resolve?urn=urn:nbn:se:uu:diva-454065 |
id |
ndltd-UPSALLA1-oai-DiVA.org-uu-454065 |
---|---|
record_format |
oai_dc |
spelling |
ndltd-UPSALLA1-oai-DiVA.org-uu-4540652021-09-30T05:23:57ZMeasuring Functional Purity In C# : Developing and implementing a technique for measuring functional purity in C#engMelker, ÖsterbergUppsala universitet, Institutionen för informationsteknologi2021functional purityfunctional programmingside-effectsdeterminismstatic analysisC#Engineering and TechnologyTeknik och teknologierComputer SciencesDatavetenskap (datalogi)Functional purity is a fundamental part of the functional programming paradigm. A function is functionally pure if it is side-effect free and deterministic. Pure functions provide many benefits compared to impure ones, including guaranteed thread-safety as well as easier testing, debugging and maintenance. But how can functional purity be measured? This thesis develops a method for statically measuring the level of functional purity in any given C# program. It also investigates problems with determining purity in object-oriented languages, with a focus on C#. Moreover, a prototype of the method is implemented in order to evaluate the method using a benchmark consisting of 11 open source repositories that use C#'s [Pure] attribute. The [Pure] attribute can be placed in front of a method declaration to indicate that it is side-effect free. Due to a number of limitations to the implementation as well as to [Pure]'s definition of functional purity, which excludes determinism, the results of the evaluation appear relatively poor. After normalizing the implementation's classification distribution for each repository, its classification of pure functions has a precision of 65% and recall 17%, and its classification of impure functions has 54% precision and 69% recall. Nevertheless, the prototype still shows the potential of the full analysis method. A complete implementation of the analysis method could potentially yield a fully working system for measuring any C# program's level of functional purity. Student thesisinfo:eu-repo/semantics/bachelorThesistexthttp://urn.kb.se/resolve?urn=urn:nbn:se:uu:diva-454065UPTEC IT, 1401-5749 ; 21031application/pdfinfo:eu-repo/semantics/openAccess |
collection |
NDLTD |
language |
English |
format |
Others
|
sources |
NDLTD |
topic |
functional purity functional programming side-effects determinism static analysis C# Engineering and Technology Teknik och teknologier Computer Sciences Datavetenskap (datalogi) |
spellingShingle |
functional purity functional programming side-effects determinism static analysis C# Engineering and Technology Teknik och teknologier Computer Sciences Datavetenskap (datalogi) Melker, Österberg Measuring Functional Purity In C# : Developing and implementing a technique for measuring functional purity in C# |
description |
Functional purity is a fundamental part of the functional programming paradigm. A function is functionally pure if it is side-effect free and deterministic. Pure functions provide many benefits compared to impure ones, including guaranteed thread-safety as well as easier testing, debugging and maintenance. But how can functional purity be measured? This thesis develops a method for statically measuring the level of functional purity in any given C# program. It also investigates problems with determining purity in object-oriented languages, with a focus on C#. Moreover, a prototype of the method is implemented in order to evaluate the method using a benchmark consisting of 11 open source repositories that use C#'s [Pure] attribute. The [Pure] attribute can be placed in front of a method declaration to indicate that it is side-effect free. Due to a number of limitations to the implementation as well as to [Pure]'s definition of functional purity, which excludes determinism, the results of the evaluation appear relatively poor. After normalizing the implementation's classification distribution for each repository, its classification of pure functions has a precision of 65% and recall 17%, and its classification of impure functions has 54% precision and 69% recall. Nevertheless, the prototype still shows the potential of the full analysis method. A complete implementation of the analysis method could potentially yield a fully working system for measuring any C# program's level of functional purity. |
author |
Melker, Österberg |
author_facet |
Melker, Österberg |
author_sort |
Melker, Österberg |
title |
Measuring Functional Purity In C# : Developing and implementing a technique for measuring functional purity in C# |
title_short |
Measuring Functional Purity In C# : Developing and implementing a technique for measuring functional purity in C# |
title_full |
Measuring Functional Purity In C# : Developing and implementing a technique for measuring functional purity in C# |
title_fullStr |
Measuring Functional Purity In C# : Developing and implementing a technique for measuring functional purity in C# |
title_full_unstemmed |
Measuring Functional Purity In C# : Developing and implementing a technique for measuring functional purity in C# |
title_sort |
measuring functional purity in c# : developing and implementing a technique for measuring functional purity in c# |
publisher |
Uppsala universitet, Institutionen för informationsteknologi |
publishDate |
2021 |
url |
http://urn.kb.se/resolve?urn=urn:nbn:se:uu:diva-454065 |
work_keys_str_mv |
AT melkerosterberg measuringfunctionalpurityincdevelopingandimplementingatechniqueformeasuringfunctionalpurityinc |
_version_ |
1719486382859091968 |