Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Analysis and Design for Functional Programming [closed]

How do you deal with analysis and design phases when you plan to develop a system using a functional programming language like Haskell?

My background is in imperative/object-oriented programming languages, and therefore, I am used to use case analysis and the use of UML to document the design of program. But the thing is that UML is inherently related to the object-oriented way of doing software.

And I am intrigued about what would be the best way to develop documentation and define software designs for a system that is going to be developed using functional programming.

  • Would you still use use case analysis or perhaps structured analysis and design instead?
  • How do software architects define the high-level design of the system so that developers follow it?
  • What do you show to you clients or to new developers when you are supposed to present a design of the solution?
  • How do you document a picture of the whole thing without having first to write it all?
  • Is there anything comparable to UML in the functional world?
like image 328
Edwin Dalorzo Avatar asked Apr 12 '12 17:04

Edwin Dalorzo


People also ask

What is a closure in functional programming?

A closure is a programming technique that allows variables outside of the scope of a function to be accessed. Usually, a closure is created when a function is defined in another function, allowing the inner function to access variables in the outer one.

What is functional programming design?

Functional programming refers to programming computers where functions serve as the primary mechanism for manipulating data. A function is said to be pure when it takes inputs, manipulates those inputs, and returns output, all without having to store some temporary or external state.

Do solid principles apply to functional programming?

Are the SOLID principles applicable to Functional Programming? Of course. Functional programmers want to separate their code to avoid crosstalk between responsibilities and users. They want to minimize the number of modules affected by a change.

Is functional programming a design patterns?

There's no simple mapping from OO design to functional design. They're very different ways of looking at the problem. Functional programming (like all styles of programming) has design patterns.


1 Answers

I'm no professional but I'll try my hand at answering some of these questions.

Would you still use use case analysis [?]

I don't see why not. Gather use cases, and design a module API that you wish to expose that satisfies the use cases. Determine whether the use cases call for a typeclass, or for just plain functions.

or perhaps structured analysis and design instead?

I'm unfamiliar with that approach, but from what I gather from the wiki article, it looks like it would work just fine.

How do software architects define the high-level design of the system so that developers follow it?

I would assume that they specify a module and the types that each part of the module should have. Again, I am not a professional, so I'm not really sure what is done in practice.

What do you show to you clients or to new developers when you are supposed to present a design of the solution?

You show the clients something that will make sense to them. If your client is savvy enough, just show them the type signatures and explain the important functions. If they are less savvy, then draw pretty pictures, or whatever you have to do. OOP makes comparisons with real world objects, while FP makes comparisons with...well...functions. The typical way to illustrate a function to newbies is to portray it as a machine where you put certain things in, and then other things come out.

How do you document a picture of the whole thing without having first to write it all?

A "picture"? Just defining the type signature for the important functions, and then leave the implementation as undefined. There's a package out there somewhere that gives you better stubs that will remind you at compile time which parts you still need to implement.

Is there anything comparable to UML in the functional world?

Um...no?

like image 197
Dan Burton Avatar answered Sep 21 '22 21:09

Dan Burton