DEV Community

loading...

Discussion on: Does your website really need to be larger than Windows 95?

Collapse
theoutlander profile image
Nick Karnik

This is something I've debated quite a bit. One of the problems is that businesses started to focus on good enough and relied heavily on better hardware. At the same time, developers started to get lazy and came up with solutions that just worked first. In most companies, they don't care about application performance especially if it is good enough and they have a huge backlog (which is very common).

The first question that I ask at the beginning of every interview is:

How can you swap two variables without using a third one?

Usually, those who have no idea will have an interesting reaction or get into an argument about the validity of the question. If they don't answer it, they end up learning something new.

Collapse
theodesp profile image
Theofanis Despoudis

For the sake of it you can using xor swap

github.com/OpenGenus/cosmos/tree/m...

Collapse
thomasjunkos profile image
Thomas Junkツ

Yes. No magic involved.
You could scare kids with the question, not software developers.

Move on.

Nothing to see here :D

Collapse
tux0r profile image
tux0r Author

At the same time, developers started to get lazy and came up with solutions that just worked first.

This is the big difference between coders and engineers, I guess. :-)

How can you swap two variables without using a third one?

I admit I had to use Notepad for that - I never had to solve this problem in my programming career. Ha! But it can be done in three elegant lines of pseudo-code. Thank you for the question, really.

Collapse
nektro profile image
Meghan (she/her)

How can you swap two variables without using a third one?

I loved this question! You should make a #challenge post with it!

Collapse
Collapse
alainvanhout profile image
Alain Van Hout

In a real-world situation where this would be needed (i.e. there is a performance issue that needs to be resolved), my first inclination would be to see if this can be addressed by modifying the higher-level architecture, rather than needing to resort to low-level mathematical trickery.