Software Development and Programming Careers (Official Discussion Thread)

Obreh Winfrey

Truly Brehthtaking
Supporter
Joined
Nov 18, 2016
Messages
20,852
Reputation
25,252
Daps
131,941
Slowly working my way back into studying for interviews. I think what makes this process so not fun is how demoralizing it is when you think you've come up with a decent solution, but when compared to the actual solution you're not even in the same galaxy. What's more is when they're like, "this is a classic application of the a$$hole Algorithm." Oh fukking sure, we all know the a$$hole Algorithm inside and out, this is textbook. fukk all the way on outta here
full
.
 

Secure Da Bag

Veteran
Joined
Dec 20, 2017
Messages
40,079
Reputation
20,339
Daps
126,270
Is it me or is reading javascript code a fukking pain in the ass? :unimpressed:Nesting so much shyt, so many brackets, cant easily determine scope of a function. Seeing curly brackets for something and being like why is that even being used :mjcry:. Anonymous functions making shyt hella confusing. Reading React code with html tags.

I have training in C#, still beginner but not a complete neophyte, but i dont remember having these kind of problems.:snoop:

Still trucking tho.:youngsabo:

If you are comfortable with C#, I hear Typescript is good to get into. It's very similar.
 
Joined
Jan 21, 2013
Messages
3,416
Reputation
514
Daps
7,621
Reppin
NULL
Some of you frontend developers maybe familiar with redux.

Out of sheer boredom I tried to partially re-implement it in c++.

Code:
#include <iostream>

#ifndef EXIT_SUCCESS
#define EXIT_SUCCESS
#endif

namespace GhettoRedux {

    template< class T, class A >
    class Store {

        T _state{} ;

        T (*_reducer)( T, A ) ;
        void (*_subscribe)() ;

        public :

        Store() { }       

        Store createStore( T (*reducer)(T, A) ) {
            _reducer = reducer ;
            return (*this) ;
        }
       
        T dispatch( A action ) {

            _subscribe() ;
           
            _state = _reducer( _state, action ) ;
            return _state ;
        }

        void subscribe( void (*subscribe)() ) {
            _subscribe = subscribe ;
        }

        T getState() const{ return _state ; }

    } ;
}

struct Action_t {
    std::string type ;
    int data ;
} ;

int counterReducer( int state, Action_t action ) {

    if ( action.type.compare( "INCREMENT") == 0 )
        return state + action.data ;                   

    else if ( action.type.compare( "DECREMENT") == 0 )
        return state - action.data ;

    return state ;       
}

int main( int argc, char** argv ) {

    GhettoRedux::Store<int, Action_t> s ;
    s.createStore( counterReducer ) ;
    s.subscribe( []() { std::cout<< "WHAT?!\n" ; }) ;

    Action_t a{ "INCREMENT", 5 } ;
    Action_t b{ "INCREMENT", 4 } ;
    Action_t c{ "DECREMENT", 3 } ;

    s.dispatch( a ) ;
    s.dispatch( b ) ;
    s.dispatch( c ) ;

    std::cout << s.getState() ;
   
    return EXIT_SUCCESS ;
}
 

Deflatedhoopdreams

Veteran
Supporter
Joined
May 29, 2012
Messages
35,791
Reputation
6,915
Daps
75,856
Reppin
The Rucker
Is it me or is reading javascript code a fukking pain in the ass? :unimpressed:Nesting so much shyt, so many brackets, cant easily determine scope of a function. Seeing curly brackets for something and being like why is that even being used :mjcry:. Anonymous functions making shyt hella confusing. Reading React code with html tags.

I have training in C#, still beginner but not a complete neophyte, but i dont remember having these kind of problems.:snoop:

Still trucking tho.:youngsabo:


Yeah JavaScript was weird to me at first coming from Python but I got a good grasp on it after the first time around
 
Top