— Code Wars: Episode VII – FP battles OOP —

Although Functional Programming (FP) and Object-Oriented Programming (OOP) are often pitted against each other (as I am doing here–guilty as charged), is this just a made-up conflict?

Let's find out…

1/

I won't go into the details of either FP or OOP in this thread (a series on OOP is coming soon, by the way)

So let's look at what they are _in brief_

2/
They are usually referred to as 'paradigms'. They're styles of programming which follow certain guidelines. They also lead to a different mindset on how to design and write computer programs

3/
They're not 'opposites' of each other in the way that 'tall' and 'short' or 'big' and 'small' are opposites

However, they do have certain rules and guidelines that are not compatible with each other. This often leads to them being seen as opposites

4/
And as with most topics in this Code Wars series, there are groups of people who are very vocal in their support for one or another of the paradigms (usually accompanied by a disdain for the other)

5/
However, I'll make the case here that the two paradigms are not enemies of each other and both have a very important role in programming. It doesn't have to be either one or the other

6/
In OOP, the object takes centre stage. It says it in the name, after all!

You create a class which acts as a template to create similar objects–that is objects which have the same attributes

7/
The attributes are data attributes and methods–that means that each object has variables attached to it to store data (data attributes) and it also has functions attached to it which act on the object itself (methods)

8/
Because of this structure in which an object carries everything it needs with it everywhere it goes, methods on objects generally change the state of the object

This means they change the values stored in the data attributes (instance variables)

9/
For example, if you have `some_object.do_something()`, this method may change `some_object.some_data`

It's doing this "behind the scenes"

Some people don't like this!

10/
For example, when using the `turtle` module, you create an instance of the `Turtle` class, let's say `fred = turtle.Turtle()`

When you write `fred.forward(10)`, the method `forward()` changes the value of the attribute `fred._position`

These are often called "side effects"

11/
As a user of the class, you don't need to know that

Whoever wrote the class made sure the behaviour of `forward()` is correct and changes whatever needs changing

12/
In FP, the function takes the pride of place as the main building block

The function is also used in a stricter way in FP than in other paradigms

Variables are treated as immutable (or _are_ immutable in programming languages which are strictly functional)

13/
Therefore, all variables needed in a function are passed as arguments. And these variables are not mutated

Copies of them are returned by the function

There are no side effects in FP

14/
For example, here's what a call in the functional style may look like:

`new_variable = do_something(some_function, some_variable)`

15/
Here's a simple example using `map()`, which is one of the built-in functions used often in the functional style:

>>> numbers = [4, 5, 6, 1, 9]
>>> output = map(float, numbers)

The variable `numbers` never changes. And no other variable will change

16/
The function `map()` returns a new object. In this case, each element of `numbers` is passed to `float()` and `output` will give you access to the values converted to floats

17/
In FP, only the information input as arguments is used and the variables used as arguments never change

This is different from OOP in which a method (which is a function) has access to other variables linked to the object and can (and will) change the state of variables

18/
So which is better?

If you browse the internet (a dangerous place to be at the best of times!) you are just as likely to find both pages singing the praises of OOP saying it's the best thing in programming and others warning you to never use OOP and use FP instead…

19/
I take the pragmatic view. There are programs I write where I feel the OOP approach is best suited. But then there are other programs in which I opt to choose the FP style.

20/
It depends. If you're comfortable with both styles and get a "feel" on the pros and cons of each one, then you'll be well placed to use the one that suits your application best

What's great about Python is that it gives you the option and the freedom to use both

21/
So, this battle ends in a truce. The two battling sides realise that there's nothing to fight about, after all, as they're really on the same side!

But beware, not everyone will observe this truce. Some will keep waging this war…

22/

More from All

APIs in general are so powerful.

Best 5 public APIs you can use to build your next project:

1. Number Verification API

A RESTful JSON API for national and international phone number validation.

🔗
https://t.co/fzBmCMFdIj


2. OpenAI API

ChatGPT is an outstanding tool. Build your own API applications with OpenAI API.

🔗 https://t.co/TVnTciMpML


3. Currency Data API

Currency Data API provides a simple REST API with real-time and historical exchange rates for 168 world currencies

🔗 https://t.co/TRj35IUUec


4. Weather API

Real-Time & historical world weather data API.

Retrieve instant, accurate weather information for
any location in the world in lightweight JSON format.

🔗 https://t.co/DCY8kXqVIK

You May Also Like

MASTER THREAD on Short Strangles.

Curated the best tweets from the best traders who are exceptional at managing strangles.

• Positional Strangles
• Intraday Strangles
• Position Sizing
• How to do Adjustments
• Plenty of Examples
• When to avoid
• Exit Criteria

How to sell Strangles in weekly expiry as explained by boss himself. @Mitesh_Engr

• When to sell
• How to do Adjustments
• Exit


Beautiful explanation on positional option selling by @Mitesh_Engr
Sir on how to sell low premium strangles yourself without paying anyone. This is a free mini course in


1st Live example of managing a strangle by Mitesh Sir. @Mitesh_Engr

• Sold Strangles 20% cap used
• Added 20% cap more when in profit
• Booked profitable leg and rolled up
• Kept rolling up profitable leg
• Booked loss in calls
• Sold only


2nd example by @Mitesh_Engr Sir on converting a directional trade into strangles. Option Sellers can use this for consistent profit.

• Identified a reversal and sold puts

• Puts decayed a lot

• When achieved 2% profit through puts then sold
1. Project 1742 (EcoHealth/DTRA)
Risks of bat-borne zoonotic diseases in Western Asia

Duration: 24/10/2018-23 /10/2019

Funding: $71,500
@dgaytandzhieva
https://t.co/680CdD8uug


2. Bat Virus Database
Access to the database is limited only to those scientists participating in our ‘Bats and Coronaviruses’ project
Our intention is to eventually open up this database to the larger scientific community
https://t.co/mPn7b9HM48


3. EcoHealth Alliance & DTRA Asking for Trouble
One Health research project focused on characterizing bat diversity, bat coronavirus diversity and the risk of bat-borne zoonotic disease emergence in the region.
https://t.co/u6aUeWBGEN


4. Phelps, Olival, Epstein, Karesh - EcoHealth/DTRA


5, Methods and Expected Outcomes
(Unexpected Outcome = New Coronavirus Pandemic)
#தினம்_ஒரு_திருவாசகம்
தொல்லை இரும்பிறவிச் சூழும் தளை நீக்கி
அல்லல் அறுத்து ஆனந்தம் ஆக்கியதே – எல்லை
மருவா நெறியளிக்கும் வாதவூர் எங்கோன்
திருவாசகம் என்னும் தேன்

பொருள்:
1.எப்போது ஆரம்பித்தது என அறியப்படமுடியாத தொலை காலமாக (தொல்லை)

2. இருந்து வரும் (இரும்)


3.பிறவிப் பயணத்திலே ஆழ்த்துகின்ற (பிறவி சூழும்)

4.அறியாமையாகிய இடரை (தளை)

5.அகற்றி (நீக்கி),

6.அதன் விளைவால் சுகதுக்கமெனும் துயரங்கள் விலக (அல்லல் அறுத்து),

7.முழுநிறைவாய்த் தன்னுளே இறைவனை உணர்த்துவதே (ஆனந்த மாக்கியதே),

8.பிறந்து இறக்கும் காலவெளிகளில் (எல்லை)

9.பிணைக்காமல் (மருவா)

10.காக்கும் மெய்யறிவினைத் தருகின்ற (நெறியளிக்கும்),

11.என் தலைவனான மாணிக்க வாசகரின் (வாதவூரெங்கோன்)

12.திருவாசகம் எனும் தேன் (திருவா சகமென்னுந் தேன்)

முதல்வரி: பிறவி என்பது முன்வினை விதையால் முளைப்பதோர் பெருமரம். அந்த ‘முன்வினை’ எங்கு ஆரம்பித்தது எனச் சொல்ல இயலாது. ஆனால் ‘அறியாமை’ ஒன்றே ஆசைக்கும்,, அச்சத்துக்கும் காரணம் என்பதால், அவையே வினைகளை விளைவிப்பன என்பதால், தொடர்ந்து வரும் பிறவிகளுக்கு, ‘அறியாமையே’ காரணம்

அறியாமைக்கு ஆரம்பம் கிடையாது. நமக்கு ஒரு பொருளைப் பற்றிய அறிவு எப்போதிருந்து இல்லை? அதைச் சொல்ல முடியாது. அதனாலேதான் முதலடியில், ஆரம்பமில்லாத அஞ்ஞானத்தை பிறவிகளுக்குக் காரணமாகச் சொல்லியது. ஆனால் அறியாமை, அறிவின் எழுச்சியால், அப்போதே முடிந்து விடும்.
Following @BAUDEGS I have experienced hateful and propagandist tweets time after time. I have been shocked that an academic community would be so reckless with their publications. So I did some research.
The question is:
Is this an official account for Bahcesehir Uni (Bau)?


Bahcesehir Uni, BAU has an official website
https://t.co/ztzX6uj34V which links to their social media, leading to their Twitter account @Bahcesehir

BAU’s official Twitter account


BAU has many departments, which all have separate accounts. Nowhere among them did I find @BAUDEGS
@BAUOrganization @ApplyBAU @adayBAU @BAUAlumniCenter @bahcesehirfbe @baufens @CyprusBau @bauiisbf @bauglobal @bahcesehirebe @BAUintBatumi @BAUiletisim @BAUSaglik @bauebf @TIPBAU

Nowhere among them was @BAUDEGS to find