Open in app
Home
Notifications
Lists
Stories

Write
Jason Vogel
Jason Vogel

Home

Mar 24

Why I “hate” optional parameters in C#
9
2

The Code Wrapper

I've been using optional parameters for decades (Oracle PL/SQL).

I've been using optional parameters for decades (Oracle PL/SQL). Thankfully later in C#. My argument in favor of them is to reduce copy-paste functions created under the guise of polymorphism (function overloading). f1(arg1, arg2,arg3) { do work } f1(arg1,arg2) { f1(arg1,arg2,'z') f1(arg1) {f1(arg1,'y') instead use to replace all 3... f1((arg1,arg2='y',arg3='z') { do work } Cleaner, less to maintain, ... But, I understand your points. It is an opinion thing. I really appreciate using them in the (what I think) is the right situation.

1 min read

I've been using optional parameters for decades (Oracle PL/SQL). Thankfully later in C#. My argument in favor of them is to reduce copy-paste functions created under the guise of polymorphism (function overloading).

f1(arg1, arg2,arg3)

{ do work }

f1(arg1,arg2)

{ f1(arg1,arg2,'z')

f1(arg1)

{f1(arg1,'y')

instead use to replace all 3...

f1((arg1,arg2='y',arg3='z')

{ do work }

Cleaner, less to maintain, ... But, I understand your points. It is an opinion thing. I really appreciate using them in the (what I think) is the right situation.

--

--


Sep 5, 2020

Setting your background in Teams (Mac or Windows)…

Today, I was talking to a director with a fuzzed-out background. Every time he fidgeted and turned his head slightly, a baby would come out of his ear. Wait, what? I get it. Um, why? Who cares? …

Remote

3 min read

Setting your background in Teams (Mac or Windows)…
Setting your background in Teams (Mac or Windows)…
Jason Vogel

Jason Vogel

Help

Status

Writers

Blog

Careers

Privacy

Terms

About

Knowable