Programming

You may need to show some code or something. I read this three times and have no idea what you’re talking about.

We do actually have decent end to end tests - since I am the lead developer and SQA department. But they’re cumbersome to run and always breaking. Also they aren’t going to catch little bugs.

But yeah the idea is that stuff only gets pushed to the production branches from trunk (except for hotfixes, which then get merged back into trunk), and trunk will build to a preprod environment for all sites. So I can run all my tests against all the sites in preprod any time a change is pushed to trunk.

If everything works the way I’m thinking anyway. I just know that messing with the single progression from dev to prod branching strategy is not standard.

In a past life we did something similar but instead of having separate branches per site (app) we did separate app releases. So basically trunk gets built for all apps on every commit. Then teams could push artifacts to their app when they wanted. I think it generally worked well. It sort of has the same effect as what you’re saying.

The problem really depends on if you have a lot of shared shit. For example, a common database can be a big source of pain because your non-prod envs have latest code per site. But then when you do the migration you can have old code talking to your migrated database.

But honestly I’ve never seen a perfect process and yours seems pretty reasonable.

Edit: Although I’m a big no to the process where people merge to the site branch and have to then merge into trunk later. I think that’s a recipe for craziness. I would require that only trunk can be merged into your site branches. Never a development/feature branch.

Super quick pseudocode:

class Widget { Color color, Shape shape };
interface IWidgetProcessor { void processWidget(Widget widget); }
class BlueCircularWidgetProcessor implements IWidgetProcessor

class WidgetProcessorFactory {
    static IWidgetProcessor getProcessor(Widget widget) {
      if(widget.color == Color.Blue && widget.shape == Shape.Circle) {
        return new BlueCircularWidgetProcessor();
      }
}

This is a normal static factory pattern but what this amounts to is a service locator - I require this service to do a thing, please new me up an instance. This is very much not how you’re supposed to do things using DI. But I can’t just register the services in my DI container in the usual way because I don’t know which implementation I want until runtime.

I understand the answer to this is probably specific to whichever DI container I’m using, but I just don’t feel like I’m structuring things the correct way here, this reeks of code smell.

Well I’m the one who handles all pushes past the development environment. The only time we merge stuff straight into prod is a hotfix that I handle.

Otherwise our flow looks like:

  1. individual branch →
  2. feature branch (optional - only used if more than one dev is working on something) →
  3. develop branch →
  4. stage branch (stable environment sometimes shown to stakeholders) →
  5. preprod branch (on production AWS account) →
  6. prod branch (in the new world I’d have multiple sibling prod branches, all spawned off of preprod)

I do everything past dev and I have some automated tools to merge the repos I want in the order I want.

So devs would just merge feature branches into the develop branch just like they do now. The CICD would build to dev versions of all the sites. But the devs would only be interested in the one they’re working on.

Also some of these sites should merge together eventually - when we turn these individual portal sites into one big shared portal. But that’s down the road and I don’t know if we’d ever merge all the sites into one.

The sites share a lot of the same back end lambdas as well. I should have mentioned that. But each also has some dedicated lambdas.

I just figured out how to supported multiple CORS domains with AWS API Gateway. Right now each site has its own API Gateway. But maybe I could combine those and save myself some hassle.

God Java is so fucking infuriating, does anyone know wtf I am actually supposed to write here?

I don’t give a shit what the type is, I just want the broadest possible declaration, but it’s really unclear what that is supposed to look like. Because Java Generics are a nailed-on kludge the IDE and compiler are supremely unhelpful.

Camel casing my eyes my eyes

Strong typing makes things easier!

I don’t understand it at all.

It resembles Curiously recurring template pattern - Wikipedia

You are trying to pass a class with 2 template params. The complaint is the first template param should be
type
BaseRequest<BaseRequest<?, ?>, BaseResponse>,
but your first param is BaseRequest<?,?>

Man that’s some crazy stuff, never seen that before

I don’t understand Java, but is there supposed to be some kind of relationship between all those question marks? Is the first type argument for Callback the same type as the type of request? If so, can you stick some T’s and S’s in there?

You have to specify the generic parameters otherwise the compiler doesnt know if the bounds are correct.
something like BaseRequest<?,?> Only works where the compiler can work without knowing what ? Is which isn’t true here because of the dependencies between the types.

Also there may be a syntax error as written that is confusing the IDE.
Assuming that Callback is an interface of which you are creating an anonymous implementation, it should be new Callback<…>() { …
The screenshot is missing the ()

You guys are so lucky I have unstuck blocked on my work computer, which means I’d have to walk all the way into the living room to post the rants about CSS that I want to post several times a day.

The problem is a) I don’t know what I’m doing, and b) I’m trying to monkey-patch someone else’s CSS. So just trying to get a label to line up often takes as long as designing a whole back end workflow.

And I know what you’d say if I posted it. You’d say “That guy’s CSS sucks!” But that’s what every CSS dev says about every other CSS dev’s work. I have never once in 23 years of programming seen a dev look at another dev’s CSS and say, “That’s some pretty, well-written CSS.” Not once.

The CSS and markup of every single site beyond hello world is a completely special snowflake combination of 1000s of things that can each be done dozens of different ways. I beat my head against the wall for an hour, finally figure it out, and I learned nothing. There’s zero satisfaction. Because I know I learned a tiny drop in the ocean of all the shit I still need to learn before CSS doesn’t make me want to punch babies.

Did you try using more !important though

1 Like

Yes - !important, &nbsp; spacers, inline styles, and setTimeouts are my go to tools.

There is but the syntax is so arcane and the IDE will never fill it in for you, it just gives incomprehensible error messages when it isn’t quite right. For the record, this is what I needed:

public <T extends BaseRequest<T, R>, R extends BaseResponse> void execute(T request) {
    
}

However, this gave rise to a new problem. I wanted to queue requests and delay execution. How do I declare a Queue of a type which stores that generic type? Or, how do I cast to that type in order to invoke execute()? As far as I’m aware, this syntax is not possible in Java.

I had to resort to a StackOverflow question to get the answer, which is that you do this:

public final class RequestWithCallback<T extends BaseRequest<T, R>, R extends BaseResponse> {

    protected T request;

    public RequestWithCallback(T request) {
        this.request = request;
    }

    public void execute() {
        thirdPartyApi.execute(request, new Callback<>() { ... });
    }

}

You encapsulate the request in another class, which takes the request in its constructor and stores it internally. Then you do everything else - the execute method and the callback and whatnot - in that class. Because you define the class to know about the structure of this generic type, it is able to call the third-party functions I need to call which require this type. But the Queue doesn’t need to know, so I can just declare a Queue<RequestWithCallback<?,?>> and when I call the void execute() method on each object in the queue, it internally has the required type information.

Just in case anyone was thinking of learning Java, I hope these anecdotes of mine are helping people avoid such a fate.

This is not a strong typing thing. Like most things wrong with Java, this is a Java thing.

Why can’t you define a Queue of that specific generic type instead of a Queue<RequestWithCallback<?,?>>
Do you intend that this queue will contain RequestWithCallback parameterized to different types?
Why not just Queue< RequestWithCallback > then or even Queue. (You will get warnings about using raw types but a @SuppressWarnings(" unchecked") annotation on the method will take care of that).

What syntax do you suggest I do that with?

I could do that but why not just write <?,?> and not suppress warnings?

Edit: I declared RequestWithCallback as final and it specifies the correct generic type, so I am absolutely assured of the Queue containing the correct type even though it isn’t constrained that way.

Edit: I declared RequestWithCallback as final and it specifies the correct generic type, …

This is what I was meant when I said

Why can’t you define a Queue of that specific generic type instead of a

Edit: fixed block quotes so that they appear properly.