Best practice for use of grid in the web (desktop browser) application, scrolling is the biggest concern

Grid is the name for the extended table component, that allows the scrolling, ordering, sorting, grouping of the columns, allows to select one or more rows, sometimes allows to select single cells and that sometimes allows to edit cells. Cells can have quite complex editors (date/time, mask-edit, color picker, file loader, and so on). Usually there are quite complex grid components available from the component vendors.

My question concerns web (for desktop browser) application. There are 2 examples how the grid can be set up:

  • https://devexpress.github.io/devextreme-reactive/react/grid/demos/featured/data-editing/ Good: the grid uses the the page scroll. Bad: the page scroll can move the column header row (column titles) away from the visible field of the page
  • https://devexpress.github.io/devextreme-reactive/react/grid/demos/featured/virtual-scrolling/ Good: the grid at least tries to provide the fixed (always visible) header row. Bad: the grid uses inner scroll and such inner scorll may (or may not) interfere with the page scroll, double scrolling is really confusing.

Grid is provided as the one component (e.g. as the React component/tag). The best use that I can imagine is: the grid component should fill all the remaining space of the page, strictly use the vertical and horizontal scroll of the page (and does not try to introduce its own internal scrolls) and that some parts of the component (e.g. fixed header row and maybe fixed footer row (with the numerical summaries for each of the column)) are position-fixed in the page so that they remain visible all the time. Does this usage description adheres to the best practices of the UX? Or maybe I should avoid the tabular grids in the modern web application (e.g. the list of panes in the stackexchange’s question timeline is one example for alternative solution). Scrolling and absolute positioning of the header and footer rows are my biggest concerns.

I am developing application of the desktop browser. This application expects quite complex actions from the user that is why I don’t predict that the application will be used from the mobile devices. Of course, I can provide the mobile version as well, but I don’t see why users should use it.

Is it bad practice to remove a resolved report from Open Bug Bounty archive?

An XSS vulnerability report was made via Open Bug Bounty, which was fixed, confirmed and a reward was made.

The reporter has marked the issue was resolved. They have further offered to remove the vulnerability from the Open Bug Bounty archive.

Being unfamiliar with Open Bug Bounty, I’m not sure if this is a good or a bad thing. The vulnerability was ethically reported in the open, so the fact that there was a report is already on the public record. The only reason I can think of to remove it is reputation protection, and even then it doesn’t seem like a very strong reason.

My inclination is to leave it in the archive by default and that removal looks suspicious.

Is there a good reason to remove a report from the archive?

Is it bad practice to create an interface only to combine two other interfaces?

I’m working on an infrastructure for inter process communication. I have created two interfaces, one to send data and another one to listen to data being sent:

public interface ISender<T> : IDisposable {     void Send(T dataToSend);      void Disconnect(); }  public interface IListener<T> : IDisposable {     event EventHandler<DataReceivedEventArgs<T>> DataReceived;      void Connect();      void Disconnect(); } 

I’ve also created another interface to allow two way communication:

public interface IComminucation<TIn, TOut> : IListener<TIn>, ISender<TOut> {  } 

But I’m not entirely comfortable with the fact that this interface is just combining the previous two interfaces and not adding anything.
To me, it feels to much like a marker interface (even though it’s not).

So the question is, do you think it’s bad practice, and if so, can you provide another alternative?

Google Kick Start Practice Round 2019 – Mural

My code exceeds the time limit on the second test set. A suggestion/hint of a better algorithm would be appreciated.

Problem

Thanh wants to paint a wonderful mural on a wall that is N sections long. Each section of the wall has a beauty score, which indicates how beautiful it will look if it is painted. Unfortunately, the wall is starting to crumble due to a recent flood, so he will need to work fast!

At the beginning of each day, Thanh will paint one of the sections of the wall. On the first day, he is free to paint any section he likes. On each subsequent day, he must paint a new section that is next to a section he has already painted, since he does not want to split up the mural.

At the end of each day, one section of the wall will be destroyed. It is always a section of wall that is adjacent to only one other section and is unpainted (Thanh is using a waterproof paint, so painted sections can’t be destroyed).

The total beauty of Thanh’s mural will be equal to the sum of the beauty scores of the sections he has painted. Thanh would like to guarantee that, no matter how the wall is destroyed, he can still achieve a total beauty of at least B. What’s the maximum value of B for which he can make this guarantee?

Input

The first line of the input gives the number of test cases, T. T test cases follow. Each test case starts with a line containing an integer N. Then, another line follows containing a string of N digits from 0 to 9. The i-th digit represents the beauty score of the i-th section of the wall.

Output

For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the maximum beauty score that Thanh can guarantee that he can achieve, as described above.

Limits

  • 1 ≤ T ≤ 100.
  • Time limit: 20 seconds per test set.
  • Memory limit: 1 GB.

Small dataset (Test set 1 – Visible)

2 ≤ N ≤ 100.

Large dataset (Test set 2 – Hidden)

For exactly 1 case, N = 5 × 10^6; for the other T – 1 cases, 2 ≤ N ≤ 100.

Sample

Input

4 4 1332 4 9583 3 616 10 1029384756 

Output

Case #1: 6 Case #2: 14 Case #3: 7 Case #4: 31 

In the first sample case, Thanh can get a total beauty of 6, no matter how the wall is destroyed. On the first day, he can paint either section of wall with beauty score 3. At the end of the day, either the 1st section or the 4th section will be destroyed, but it does not matter which one. On the second day, he can paint the other section with beauty score 3.

In the second sample case, Thanh can get a total beauty of 14, by painting the leftmost section of wall (with beauty score 9). The only section of wall that can be destroyed is the rightmost one, since the leftmost one is painted. On the second day, he can paint the second leftmost section with beauty score 5. Then the last unpainted section of wall on the right is destroyed. Note that on the second day, Thanh cannot choose to paint the third section of wall (with beauty score 8), since it is not adjacent to any other painted sections.

In the third sample case, Thanh can get a total beauty of 7. He begins by painting the section in the middle (with beauty score 1). Whichever section is destroyed at the end of the day, he can paint the remaining wall at the start of the second day.

My solution

T = int(input())                # number of tries in test set  for i in range(1,T+1):     N = int(input())            # number of sections of wall     score_input = input()       # string input of beauty scores     beauty_scores = [int(x) for x in score_input]      muralLength = (N+1)//2     bestScore = 0               # to obtain best beauty score      for k in range((N+2)//2):   # the no. of possible murals         score = sum(beauty_scores[k:k+muralLength])          if score > bestScore:             bestScore = score      print("Case #{}: {}".format(i, bestScore)) 

Further details

My code worked fine for the first test set, but the time limit was exceeded for the second. The most likely outcome is that with the test case N = 5 x 10^6, there was far too many mural options for the code to check (2500001 to be exact.)

Is it bad practice to couple committing changes to a db based on api response code?

Let’s say I have an api endpoint with a couple of service functions like so

```python # API endpoint @route(...) def create_a_car():     service.create_wheels()     service.create_engine()     ... # and so on      return Response(result=car, status_code=200)   # service def create_wheels():     # create wheels     session.flush()     # session.commit()     ... # do something with the wheels.id  def create_engine():     # create wheels     session.flush()     # session.commit()     ... # do something with the engine.id   # middleware @after_request def commit(response):     if response.status_code == 200:         try:             session.commit()         except Error:             session.rollback() ``` 

The reason I have a middleware that does the commit, is because I want to limit the number commit calls, because the transactions would be closed after every commit, and having to restart them every time seem unnecessary. Additionally, because create_a_car() depends on different database operations, having individual commits in each of those functions could result in an inconsistent database state. E.g create_wheels() succeeded but create_engine() failed. Now there are un-associated wheels in the database.’

But coupling database logic with HTTP status codes seem a bit dangerous? As they’re different things, or would it not matter in this case? Are there better approaches?

Best Practice – Magento Versioning Backwards Compatibility

I have a module that I developed against 2.3.0, then with the release of 2.3.1 it completely changed the layout of one of the pages that my module overrode the template of.

Lets say that the original version of my module was 1.1.1, I could now create a new version 1.1.2 that deals with breaking changes in 2.3.1.

I end up with this situation:

  • 1.1.1 is not compatible with 2.3.1
  • 1.1.2 is not compatible with 2.3.0

Now, I want to add a small new feature to my module and create a new version 1.2.0, but it is impossible to create a single version that is compatible with 2.3.0 and 2.3.1.

What is the best practices in versioning? Should I keep separate branches of my module to deal with each different version of Magento?

Am I following good python programming practice for multiple functions?

I’m currently a 3rd year computer science student and lecturers have never checked the readability and maintainability of code. We were only marked on our outputs and as such I’ve written some truly horrible looking code in the past. I’m trying to work on that and one thing I’ve learned is that it’s a good idea to put things in functions to make testing and maintaining code easier.

I completed the following question: https://www.codewars.com/kata/catching-car-mileage-numbers/train/python

My code is: https://pastebin.com/dtTYmTAs

I’ve put in pastebin as the formatting is getting messed up here due to spaces in Python.

Would I be fine if I coded this at a business or have I created too many functions or taken too rudimentary approaches to each function?

One thing I did consider is to add another function to make the number is above 99

def great_enough(number):     if number>99:         return True 

Best practice for multi-language mails?

I have to design an email invitation for a customer. The customer offers a service for companies to communicate with their suppliers. So the companies enter the email addresses of their suppliers, and these are invited to create an account. Since I only have the addresses, I have no idea what language the invited person speaks. I think I’ll have to include the text in several languages in the email or provide links “read in English”, “lea en Español”, “auf Deutsch lesen” and so on.

Any better ideas? Do you know examples of such emails that can be an inspiration?