Skip to content

Instantly share code, notes, and snippets.

Avatar

Kislay Verma kislayverma

View GitHub Profile
@kislayverma
kislayverma / method-too-granular
Created May 29, 2021
Method is now too granular
View method-too-granular
public Slot makeAppointment(Doctor d, Hospital h, Patient p, Date startTime, Date endTime) throws Exception {
if (!isHospitalOpen(h, startTime, endTime)) {
throwException("Hospital isn't open in this time period");
}
Slot s = getFreeSlotForDoctor(d, startTime, endTime);
if (s == null) {
throwException("Doctor is not free in this time period");
}
Slot bookedSlot = createAppointment(s, d, p);
notifyDoctor(bookedSlot, d, p);
@kislayverma
kislayverma / method-still-okay
Last active May 29, 2021
Method is still kind of ok but getting worse
View method-still-okay
public Slot makeAppointment(Doctor d, Hospital h, Patient p, Date startTime, Date endTime) throws Exception {
if (!isHospitalOpen(h, startTime, endTime)) {
throw new Exception("Hospital isn't open in this time period");
}
Slot s = getFreeSlotForDoctor(d, startTime, endTime);
if (s == null) {
throw new Exception("Doctor is not free in this time period");
}
Slot bookedSlot = createAppointment(s, d, p);
notifyDoctor(bookedSlot, d, p);
@kislayverma
kislayverma / method-in-workflow-style
Created May 29, 2021
Original method broken down to workflow style
View method-in-workflow-style
public Slot makeAppointment(Doctor d, Hospital h, Patient p, Date startTime, Date endTime) throws Exception {
if (!isHospitalOpen(h, startTime, endTime)) {
throw new Exception("Hospital isn't open in this time period");
}
Slot s = getFreeSlotForDoctor(d, startTime, endTime);
if (s == null) {
throw new Exception("Doctor is not free in this time period");
}
Slot bookedSlot = createAppointment(s, d, p);
notifyDoctor(bookedSlot, d, p);
@kislayverma
kislayverma / method-doing-multiple-things
Last active May 29, 2021
Method doing multiple things
View method-doing-multiple-things
public Slot makeAppointment(Doctor d, Hospital h, Patient p, Date startTime, Date endTime) throws Exception {
// Check if hospital is open during this time period
String hospitalServiceBaseUrl = ConfigReader.readConfigName("hospitalServiceBaseUrl");
HospitalService hospitalService = new HospitalService(hospitalServiceBaseUrl);
DateRange range = hospitalService.getWorkingHours();
if (!range.contains(startTime) || !range.contains(endTime)) {
throw new Exception("Hospital isn't open in this time period");
}
// Check if doctor has no other appointment in this time period
String scheduleServiceBaseUrl = ConfigReader.readConfigName("scheduleServiceBaseUrl");
@kislayverma
kislayverma / ActionDefinedUpdateApi.java
Created Apr 10, 2021
AN update API with clearly defined actions on entity
View ActionDefinedUpdateApi.java
public class Booking {
String uniqueId;
User guest;
User host;
Date bookingTime;
Date confirmationTime;
Date cancellationTime;
Status status; //PENDING, CONFIRMED, CANCELLED_BY_GUEST, CANCELLED_BY_HOST
User lastUpdatedBy;
}
@kislayverma
kislayverma / SpecificCancellationApi.java
Created Apr 10, 2021
Specific cancellation APIs reveal the model by explain what all can be done
View SpecificCancellationApi.java
public class Booking {
String uniqueId;
User guest;
User host;
Date bookingTime;
Date confirmationTime;
Date cancellationTime;
Status status; //PENDING, CONFIRMED, CANCELLED_BY_GUEST, CANCELLED_BY_HOST
User lastUpdatedBy;
}
View generic-update-api.java
public class Booking {
String uniqueId;
User guest;
User host;
Date bookingTime;
Date confirmationTime;
Date cancellationTime;
Status status; //PENDING, CONFIRMED, CANCELLED_BY_GUEST, CANCELLED_BY_HOST
User lastUpdatedBy;
}
@kislayverma
kislayverma / steve-yegge-platform-rant-follow-up.md
Created Dec 26, 2019
The one after platforms where Steve Yegge shares Amazon war stories
View steve-yegge-platform-rant-follow-up.md

By Steve Yegge

Last week I accidentally posted an internal rant about service platforms to my public Google+ account (i.e. this one). It somehow went viral, which is nothing short of stupefying given that it was a massive Wall of Text. The whole thing still feels surreal.

Amazingly, nothing bad happened to me at Google. Everyone just laughed at me a lot, all the way up to the top, for having committed what must be the great-granddaddy of all Reply-All screwups in tech history.

But they also listened, which is super cool. I probably shouldn’t talk much about it, but they’re already figuring out how to deal with some of the issues I raised. I guess I shouldn’t be surprised, though. When I claimed in my internal post that “Google does everything right”, I meant it. When they’re faced with any problem at all, whether it’s technical or organizational or cultural, they set out to solve it in a first-class way.

Anyway, whenever something goes viral, skeptics start wondering if it was faked or staged. My accident

@kislayverma
kislayverma / steve-yegge-google-platform-rant.md
Created Dec 26, 2019
A copy (for posterity) of Steve Yegge's internal memo in Google about what platforms are and how Amazon learnt to build them
View steve-yegge-google-platform-rant.md

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't really have SREs and they make engineers pretty much do everything,